Jump to content

Mysql CURRENT_TIMESTAMP and timezones


Jonob

Recommended Posts

Hi all,

 

I have a timestamp field in a mysql database with a default value of 'CURRENT_TIMESTAMP'.

 

My server is located in GMT, but I may have a user in a different timezone, lets say GMT + 10. So, he saves a record into the table at 09.00AM on 20 Oct 2009, but db records this as 19 Oct 2009 23:00:00.

 

User then wants to see when record was created, and it says 19 October..and then scratches his head because he is sure that he saved it on 20 October.

 

Is there any way to get around this, other than having to save every user's timezone in the db? i.e. would I have to manually calculate the time for each insert in php, rather than relying on Mysql's CURRENT_TIMESTAMP as a default?

 

I am hoping that there is a simpler way to get around this...

Link to comment
Share on other sites

I too am having this problem. When data is submitted, it submits it under the server's current timezone. I want my website to display the data with how long ago the data was submitted.

 

For example: The server is 3 hours ahead of me. If I submit data at 13:00, and I view the data on my website at 3 hours later, I want it to say "Age = 3 hours old".

 

At the moment, it says it is 3 hours old as soon as it's submitted. Anyone help?

Link to comment
Share on other sites

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.