IM在我的網站上顯示日期和時間的量,直到某個事件開始,我創建了下面的代碼:PHP的時間和小時小於零(0)
我的問題:
天數和小時雲在負(小於零)時,有沒有天,其餘的沒有什麼不時間應顯示
//cur date
$curDate = date("Y-m-d");
//future date + 7days
$date = date('Ymd');
$date = strtotime($date);
$date = strtotime("+7 day", $date);
$date = date('Y-m-d', $date);
//return days and hours remaining until KO
$calcDate = $gameDate.$time;
$calcDate = strtotime(str_replace('/', '-', $gameDate));
$remaining = $calcDate - time();
$days_remaining = floor($remaining/86400);
$hours_remaining = floor(($remaining % 86400)/3600);
//echo in index.php display in if statments
if($days_remaining<0&&$hours_remaining<0){
echo'';
}
if($days_remaining == 0){
echo 'Starts In: <span class="timeSpan">'.$hours_remaining.'</span> Hours';
}
else if($days_remaining != 0){
echo' Starts In: <span class="timeSpan">'.$days_remaining.'</span> Days And <span class="timeSpan">'.$hours_remaining.'</span>Hours';
}
你試過'如果($ DAYS_REMAINING <= 0){ '在最後的if/else語句中? –
您的代碼不完整。什麼是時間和比賽日期? – wonderb0lt
@caCtus即時通知 –