PHP 4
$a = 1359994013 (Mon, 04 Feb 2013 16:06:53)
$b = 1359997483 (Mon, 04 Feb 2013 17:04:43)
如何计算这两个时间戳之间的差异并将结果显示为:
w days, x hours, y mins, z seconds.
例如:0 天、0 小时、58 分钟、10 秒
谢谢 :)
如果您参与计算并坚持使用 PHP 4:
$a = 1359994013;
$b = 1359997483;
$difference = $b-$a;
$second = 1;
$minute = 60*$second;
$hour = 60*$minute;
$day = 24*$hour;
$ans["day"] = floor($difference/$day);
$ans["hour"] = floor(($difference%$day)/$hour);
$ans["minute"] = floor((($difference%$day)%$hour)/$minute);
$ans["second"] = floor(((($difference%$day)%$hour)%$minute)/$second);
echo $ans["day"] . " days, " . $ans["hour"] . " hours, " . $ans["minute"] . " minutes, " . $ans["second"] . " seconds";
这给你0 days, 0 hours, 57 minutes, 50 seconds
。
您可以尝试使用日期功能: