It is necessary to calculate the time to the nearest necessary hour, the period - every 6 hours, it is 00, 6, 12, 18. Give the time to this hour in seconds. Stopped at the very end.
function itime() { //Текущее время $nt = date('G:i:s', time()); list($hour, $min, $sec) = explode(':', $nt); //Узнаём ближайший час if ($hour >= 0 && $hour < 6) { $wayth = 6; } if ($hour >= 6 && $hour < 12) { $wayth = 12; } if ($hour >= 12 && $hour < 18) { $wayth = 18; } if ($hour >= 18 && $hour < 0) { $wayth = 0; } //Считаем время до этого часа } echo itime();
strtotime('6 hours')- Naumov