Hello, how can i get time left till 00:00:00

March 17, 2011 at 09:35:23
Specs: Windows XP, AMD Samphron 3000+, 1536 RAM
Hello, how can i get time left till 00:00:00 . I need to get theese values in Hours:Minutes:Seconds . I need to use them in other script.

See More: Hello, how can i get time left till 00:00:00

Report •


#1
March 18, 2011 at 03:54:41
Use the function:

$today = date("H:i:s");

to get the current time as a string (as, for example "14:23:45". The rest is simply a matter of chopping the string up to get the individual values and then doing a little simple arithmetic.


Report •

#2
March 18, 2011 at 15:51:19

$d = date_diff( new DateTime("now"), new DateTime("tomorrow"));
echo $d->format("%H:%I:%S");

Report •

#3
March 18, 2011 at 16:20:39
Thank you guys for the great reply's and for helping, but i made a better solution by myself, by investigating some formulas :

date_default_timezone_set('Europe/Riga');
$actualDate = time();
$targetDate = mktime(0, 0, 0, date("m") , date("d")+1, date("Y"));
$secondsDiff = $targetDate - $actualDate;
$remainingDay = floor($secondsDiff/60/60/24);
$remainingHour = floor(($secondsDiff-($remainingDay*60*60*24))/60/60);
$remainingMinutes = floor(($secondsDiff-($remainingDay*60*60*24)-($remainingHour*60*60))/60);
$remainingSeconds = floor(($secondsDiff-($remainingDay*60*60*24)-($remainingHour*60*60))-($remainingMinutes*60));


Report •
Related Solutions


Ask Question