可能的重复项:
Number of seconds from now() to Sunday midnight
Calculates difference between two dates in PHP
大家好,
在我的项目中,我需要计算两个日期之间的差(以秒为单位
例如:
$firstDay = "2011-05-12 18:20:20";
$secondDay = "2011-05-13 18:20:20";
那么我应该得到86400秒的,也就是24小时。
与之类似
$firstDay = "2011-05-13 11:59:20";
$secondDay = "2011-05-13 12:00:20";
它应该返回60秒。
我在stackoverflow But they only deals
中读到了很多关于2分钟字段的差异的问题,比如11:50:01和12:10:57
发布于 2011-05-13 15:13:33
$timeFirst = strtotime('2011-05-12 18:20:20');
$timeSecond = strtotime('2011-05-13 18:20:20');
$differenceInSeconds = $timeSecond - $timeFirst;
然后,您将能够使用秒来查找分钟、小时、天等。
https://stackoverflow.com/questions/5988450
复制相似问题