cags Posted October 25, 2009 Share Posted October 25, 2009 The server I'm working with is hosted in America so all times inserted into the database are coming out 5 hours differen't to what I want them to. I attempted placing the following in my Header file... date_default_timezone_set('Europe/London'); But it doesn't seem to have worked, am I missing something? :-\ Link to comment https://forums.phpfreaks.com/topic/178952-solved-default-timezone/ Share on other sites More sharing options...
smerny Posted October 25, 2009 Share Posted October 25, 2009 http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_utc-timestamp Link to comment https://forums.phpfreaks.com/topic/178952-solved-default-timezone/#findComment-944134 Share on other sites More sharing options...
salathe Posted October 25, 2009 Share Posted October 25, 2009 Does echo date('r'); give you the right date and timezone? Is MySQL's timezone set to an American timezone? Link to comment https://forums.phpfreaks.com/topic/178952-solved-default-timezone/#findComment-944136 Share on other sites More sharing options...
smerny Posted October 25, 2009 Share Posted October 25, 2009 I think it's good just to use UTC when you insert, and if you need to, use CONVERT_TZ() when selecting it will provide more flexibility if you need to in the future (like people having timezone settings for example) Link to comment https://forums.phpfreaks.com/topic/178952-solved-default-timezone/#findComment-944138 Share on other sites More sharing options...
cags Posted October 25, 2009 Author Share Posted October 25, 2009 Does echo date('r'); give you the right date and timezone? Is MySQL's timezone set to an American timezone? Gives me... Sun, 25 Oct 2009 13:10:13 -0400 Which I'm sure you know (since your profile shows you as being in the UK) is not correct. It's 4 hours out making it east coast America I believe. I'm not sure if MySQL's timezone is set to American or not, I suspect it is since PHP is. Using my current code I don't see how it's relevant though as my code inserts to the database using something along the line of... post_time = date("Y-m-d H:i:s") Link to comment https://forums.phpfreaks.com/topic/178952-solved-default-timezone/#findComment-944145 Share on other sites More sharing options...
salathe Posted October 25, 2009 Share Posted October 25, 2009 Gives me... Sun, 25 Oct 2009 13:10:13 -0400 Odd. What does the following give: <?php error_reporting(E_ALL | E_STRICT); date_default_timezone_set('Europe/London'); var_dump( date_default_timezone_get(), ini_get('timezone.default'), getenv('TZ') ); echo date('r'); Link to comment https://forums.phpfreaks.com/topic/178952-solved-default-timezone/#findComment-944153 Share on other sites More sharing options...
cags Posted October 25, 2009 Author Share Posted October 25, 2009 I feel like a certain french writer who wrote about some musketeers... I'd added date_default_timezone_set to the Header file which was an include, and I was inserting into the database before including the Header. Rather embarrasing, but nevermind, at least I/we got to the bottom of it. Link to comment https://forums.phpfreaks.com/topic/178952-solved-default-timezone/#findComment-944166 Share on other sites More sharing options...
salathe Posted October 25, 2009 Share Posted October 25, 2009 Dumby. Link to comment https://forums.phpfreaks.com/topic/178952-solved-default-timezone/#findComment-944193 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.