我試圖讓剩下的天,小時和分鐘到使用php的某個日期。PHP:剩下幾天,幾小時和幾分鐘到某個日期?
但是我從我的代碼很奇怪的輸出,看起來像這樣:
-16828 days and -11 hours and -21 minutes and -24 seconds
未來一段時間內存儲在該格式的mysql數據庫:
29/01/2016 7pm
所以我徑自並做到這一點:
$Draw_time = "29/01/2016 7pm";
$date = $Draw_time;
$timestamp = strtotime($date);
$new_date = date('Y-m-d a',$timestamp);
$seconds = strtotime($new_date) - time();
$days = floor($seconds/86400);
$seconds %= 86400;
$hours = floor($seconds/3600);
$seconds %= 3600;
$minutes = floor($seconds/60);
$seconds %= 60;
echo "$days days and $hours hours and $minutes minutes and $seconds seconds";
但是,當我運行此代碼,我得到上述奇怪的輸出!
據我所知,這可能是由於一些原因,但我能想到的唯一的事實是,我在使用我的格式a
?
請問有人能就這個問題提出建議嗎?
的[PHP倒計時日期](http://stackoverflow.com/questions/1735252/php-countdown-to-date) –
的[的strtotime可能的複製()不使用dd工作可能的重複/ mm/YYYY格式](http://stackoverflow.com/questions/2891937/strtotime-doesnt-work-with-dd-mm-yyyy-format) – AleFranz
你使用哪種類型的商店'29/01/2016年7月下旬? :) –