2次()值之间的差异
我有2个时间()值,例如:
1379078542
1379078574
我该如何解决他们的问题,并将输出显示为年,月,周,日,小时,分钟,秒等。
上面的2个值有32秒的差别,所以在这种情况下,我想显示32秒。
$datetime1 = new DateTime('@1379078542');
$datetime2 = new DateTime('@1379078574');
$interval = $datetime1->diff($datetime2);
$elapsed = $interval->format('%y years, %m months, %a days, %h hours, %i minutes, %S seconds');
$elapsed = str_replace(array('0 years,', ' 0 months,', ' 0 days,', ' 0 hours,', ' 0 minutes,'), '', $elapsed);
$elapsed = str_replace(array('1 years, ', ' 1 months, ', ' 1 days, ', ' 1 hours, ', ' 1 minutes'), array('1 year, ', '1 month, ', ' 1 day, ', ' 1 hour, ', ' 1 minute'), $elapsed);
echo $elapsed;
在行动中看到它
链接地址: http://www.djcxy.com/p/58973.html上一篇: Difference between 2 time() values
下一篇: IBM iSeries Combine Date & Time decimal fields to compare current time