Hello forums how do I convert a strtotime() value to a time format
$start = '13:00:00' ;
$end = '21:00:00';
$time = strtotime($start) - strtotime($end);
w/c gives me 28800
How do I convert it to time format 8:00:00
Tnx
Hello forums how do I convert a strtotime() value to a time format
$start = '13:00:00' ;
$end = '21:00:00';
$time = strtotime($start) - strtotime($end);
w/c gives me 28800
How do I convert it to time format 8:00:00
Tnx
$start = '13:00:00' ;
$end = '21:00:00';
$time = date( "h:i:s", strtotime($end) - strtotime($start) ) ;
echo $time ;
In this case you have to get end and start the right way round, and the answer I got was
09:00:00
Gee Tnx Cups but I swear I got 08:00:00, is this a timezone issue?
The timezones are the same in the execution of a script - Cups’ script for some reason did the math wrong. 08:00:00 should be the correct answer…
What did you expect the output to be? There are 8 hours between 1pm and 9pm.
P.S. There will be timezone issues unless your default timezone aligns with GMT. Either use date_default_timezone_set[/font] or, preferably, [font=monospace][url=http://php.net/gmdate]gmdate.