【发布时间】:2011-10-09 04:48:51
【问题描述】:
基本上我需要显示距离指定时间还有多少时间,或者如果它过去了,那么它已经过去了多少时间。
原始字符串如下所示:07/20/2011 01:13 am
编辑:从 javascript 转换为 php:
//get local time in UTC format
echo gmdate("Y/m/d\TH:i:s\Z");
echo '<br />';
//convert time to UTC
$the_date = strtotime("07/20/2011 01:13 am");
echo date("Y/m/d\TH:i:s\Z",$the_date);
执行上述操作让我可以使用这些:
//local time
2011/07/20T19:49:39Z
//specified time
2011/07/20T01:13:00Z
如何获取指定时间和本地时间并使其显示类似于以下示例的内容:
Started 36 mins ago
Will start in 33 mins
Will start in 6 hrs 21 mins
Will start in 4 days 4 hrs 33 mins
【问题讨论】:
-
我发现了一个函数,可以用来增加或减少日期的分钟数,并且可以很容易地修改它以增加或减少两个日期:stackoverflow.com/questions/1197928/…
标签: php javascript datetime date xhtml