|
 |
|
ช่วยเรื่อง การ count timestamp หน่อยครับ อยากให้ count เฉพาะ ภายใน 5 นาทีนี้ |
|
 |
|
|
 |
 |
|
ลองใช้การ Diff TimeStamp ดูครับ
Code (PHP)
<?php
// Author: el pinche <fitorec>
function otherDiffDate($end='2020-06-09 10:30:00', $out_in_array=false){
$intervalo = date_diff(date_create(), date_create($end));
$out = $intervalo->format("Years:%Y,Months:%M,Days:%d,Hours:%H,Minutes:%i,Seconds:%s");
if(!$out_in_array)
return $out;
$a_out = array();
array_walk(explode(',',$out),
function($val,$key) use(&$a_out){
$v=explode(':',$val);
$a_out[$v[0]] = $v[1];
});
return $a_out;
}
?>
Ex 1
<?php
echo otherDiffDate();
?>
Result
Years:08,Months:01,Days:22,Hours:17,Minutes:5,Seconds:26
Ex 2
<?php
print_r(otherDiffDate('2020-01-01 20:30:00',true));
?>
Result
Array
(
[Years] => 07
[Months] => 08
[Days] => 15
[Hours] => 03
[Minutes] => 3
[Seconds] => 48
)
|
 |
 |
 |
 |
Date :
2013-01-11 13:23:58 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|