I am not sure why strtotime()
in PHP returns different result in different timezone even though same date is given as parameter, does anyone know the answer? I
strtotime
gives different results in different timezones because it takes timezones into account...
From strtotime's manual:
The function expects to be given a string containing an English date format and will try to parse that format into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 UTC)
This function will use the TZ environment variable (if available) to calculate the timestamp. Since PHP 5.1.0 there are easier ways to define the timezone that is used across all date/time functions. That process is explained in the
date_default_timezone_get()
function page.
Have a look at mktime().
Since PHP 5.1, you can use date_default_timezone_set before calling mktime
or strtotime
.