I am using following code
list($date, $time) = explode(' ', $row['created_at']);
list($year, $month, $day) = explode('-', $date);
list($hour, $minute, $second) = explode(':', $time);
$timemodified = mktime($hour, $minute, $second, $month, $day, $year);
$threshold = time() - 6;
echo $threshold.'</br>';
echo $timemodified.'</br>';
echo $timemodified - $threshold;
It outputs
1428631618
1428643990
12372
The modified time is just two minutes ago. Why is the difference so big I am just subtracting six seconds. Am I missing sommething?
It's because the $threshold
time is not really 6 seconds. You can use strtotime()
function to subtract 6 seconds from your time
$newTime = strtotime('-6 seconds', $timemodified);
echo date('Y-m-d H:i:s', $newTime);
hope this helps. For my example see this: http://codepad.org/cRp858RG
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.