Hmm… Well actually the strtotime function returns the current time in the “default” timezone by default. The default timezone is not
necessarily your php.ini file’s timezone as it can be overridden with a call to the php function date_timezone_set. Everyone have a headache yet?
The best way to determine which timezone is affected by strtotime() is to stick in a command like (assuming
you have the devel module enabled): dsm(date_default_timezone_get());
On my drupal installation this does not return GMT number. So what you want to do if you want GMT time is
to append “GMT” to the time.
Check out the following code snippet:
$output =
'<pre>';
$output .= date_default_timezone_get() .
"\n";
$output .= strtotime('January
1 1970 00:00:0').
"\n";
$output .= strtotime('January
1 1970 GMT') .
"\n";
$output .=
'</pre>';
On my box this returns.
America/Los_Angeles
28800
0
Hope that helps.
From: support-bounces@drupal.org [mailto:support-bounces@drupal.org]
On Behalf Of
Sent: Thursday, February 28, 2013 7:55 AM
To: support drupal
Subject: [support] Time Zones
Being blond, confusion is my normal state, but time zones are threatening to ruin what's left of my mental health.
In D7, we set the site's default time zone (America/New_York for me). Since it then displays the correct time, I have to assume that
the server is running on GMT. Is that correct?
If I read the PHP manual correctly, the strtotime() function will create a GMT time. Is that correct?
So if I ask the user to tell me their timezone when they enter a time, I can stick that on the end of the string that I pass to strtotime()
and get a GMT timestamp?