I'm using the getdate function, and I'm intending to use it to parse a time interval, in seconds, into days, minutes, hours, etc. However, I'm surprised that getdate(0)['hours']
is 1. What's going on here?
FWIW, the complete output I get is:
Array
(
[seconds] => 0
[minutes] => 0
[hours] => 1
[mday] => 1
[wday] => 4
[mon] => 1
[year] => 1970
[yday] => 0
[weekday] => Thursday
[month] => January
[0] => 0
)
January 1, 1970, 00:00 GMT
was 01:00
in BST (British Standard Time). Your server presumably has that time zone set.
Use date_default_timezone_set()
to change the time zone, or use the new DateTime class that is completely timezone aware.
My guess would be that you are living in the UK.
PHP is configured to use the local timezone of your country. This results in a time of 1:00: GMT + 1 hour for the Daylight Savings.
There are 2 possible solutions:
I suggest the first solution; your script might need to pretty print individual times, along with the intervals, which you want to have converted to your local timezone.