Am using strtotime
to get seconds past 1 January 1970
, but am not understanding that why am getting -3600
if the clock is set to 12.00AM
and I get 0
when the clock is set to 1 AM
, so what's with that 1 HOUR
? Is it an issue with the timezone?
echo 'I Expect 0 Here '.strtotime('1st January 1970').'<br />';
//This gives me -3600
echo 'I Expect 3600 Here '.strtotime('1st January 1970 01.00AM');
//This gives me 0
P.S I've not set any Time Zone in my PHP file or I've not even modified my .ini file (Fresh Installed XAMPP)
Update : Time-Zone : Europe/Berlin
It's most likely due to your local time zone.
What's the output of
var_dump(date_default_timezone_get());
on that machine?
You can also check the difference between mktime and gmmktime
echo " mktime: ", mktime(), "\n";
echo " gmmktime: ", gmmktime(), "\n";
Your timezone must be set to UTC+1. Midnight in your timezone happened an hour before midnight in UTC, which explains the offset of -3600 seconds.
You can set the timezone to UTC to get the expected result:
date_default_timezone_set('UTC');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With