Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.