基本上我需要顯示多長時間,直到指定的時間,或者它傳遞了多少時間,因爲它通過。如何顯示時間,直到指定日期爲止javascript或php
原始字符串看起來就像這樣: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
我發現,可用於從一個日期添加或減去分鐘的功能,並且它可以很容易以加上或減去兩個日期進行修改:http://stackoverflow.com/questions/ 1197928/how-to-add-30-minutes-to-javascript-date-object/1214753#1214753 –