【发布时间】:2017-05-16 06:09:50
【问题描述】:
是否有任何本地函数可以获取两个时间戳之间的差异?我想得到两个时间戳的分钟差。
编辑:对不起,但实际上我只是想要两个 Unix 时间戳的差异。
$date = new DateTime();
$date1_timestamp = $date->getTimestamp();
sleep('120');
$date2_timestamp = $date->getTimestamp();
function get_unix_timestamp_minutes_difference($start, $end) {
/*
Some code for return the difference between two unix timestamps
*/
}
echo get_timestamp_minutes_difference($date1_timestamp, $date2_timestamp);
【问题讨论】:
-
$to_time = strtotime("2008-12-13 10:42:00"); $from_time = strtotime("2008-12-13 10:21:00");回声回合(($to_time - $from_time)/ 60,2)。 "分钟";
标签: php timestamp unix-timestamp difference