Jump to content

[SOLVED] Default TimeZone


cags

Recommended Posts

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

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")

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');

::) 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. :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.