I’m having a bit of trouble with the mktime function. On my production server, if I execute the following:
echo '<p>' . mktime(24, 0,0, 8,29,2009) . ' - 12pm</p>';
echo '<p>' . mktime(23, 0,0, 8,29,2009) . ' - 11pm</p>';
echo '<p>' . mktime(22, 0,0, 8,29,2009) . ' - 10pm</p>';
And then convert those timestamps back to readable format (using http://www.unixtimestamp.com for quick conversion), the times are all off by one hour. I originally thought this was a problem with 2400 VS 0000, but that wouldn’t account for the other dates being off.
Any ideas?
Your server has a different time zone than you are expecting. Unix timestamps are measured in seconds since 1.1.1970 00:00:00 GMT, so you have a hidden time zone conversion in your code. You can either
gmmktime()to create a timestamp for a GMT date,date_default_timezone_set().