【发布时间】:2012-12-10 10:25:42
【问题描述】:
基本上我想获得剩余时间到期。我在 php 5.3.x 中很容易做到,如下所示
$now = new DateTime();
$future_date = new DateTime($enddate);
$interval = $future_date->diff($now,false); // ->diff will not work on 5.2.x
$interval->format("%d d, %h h, %i m");
我怎样才能在 PHP : 5.2.x(5.2.17) 中做一些事情。
我尝试了什么:
new DateTime(date('Y-m-d H:i:s', $now->format('U') - $future_date->format('U')));
未提供预期结果。
【问题讨论】:
-
您可以在这里查看 cmets 中的几种解决方案:php.net/manual/en/function.date-diff.php
标签: php date datetime unix-timestamp