Reputation: 298
I am using strtotime
function with 28th October, 2014 date like echo strtotime('2014-10-28')
on local and staging servers.
Local server result: 1414468800
Staging server result: 1414425600
Why there is difference between the results on different servers and how can I fix this issue?
Upvotes: 1
Views: 879
Reputation: 1203
i think it is because the two servers have diff timezones..
you can atleast do this:
$date = '2014-10-28'; // date
$timezone = 'America/Virgin'; // timezone you prefer
$date = new DateTime($date , new DateTimeZone($timezone));
echo $date->getTimestamp();
Upvotes: 3
Reputation: 27305
You can set the timezone in your php.ini
file. The value is
date.timezone = "Americas/New_York"
I think this values are different on your systems.
Otherwise you have to set it in your scripts but i think its better to set it in your configuration.
Upvotes: 1