Jump to content

Changing Timezones


rklockner

Recommended Posts

I have inheritted an enormous code base that was never written to consider the timezone a user is in.  I have been tasked with adding in a timezone field for users to select, then adjust the time everywhere it is used.

 

There are literally hundreds (if not thousands) of places where the time is displayed. 

 

Hopefully there is a possibility to adjust this without having to adjust every MySQL query.

 

Ideally,

1 - The query calls the data on the server

2 - Either PHP or MySQL recognizes it as a date and adjusts it based on the user's timezone automatically.

 

NOTE: I am familiar with how the user can select their timezone in PHP (date_default_timezone_set)

 

Not Ideal (as this would take weeks to implement),

 

function scriptToChangeTZ($datetime){

    ...adjust to new timezone code

}

 

$datetime = /*date from MySQL query */

 

$new_datetime = scriptToChangeTZ($datetime);

Link to comment
Share on other sites

From the responses I am getting, I think I need to:

1 - create a function to adjust the timezone

2 - start implementing the function across the software

3 - gradually implement the new function on all date/time strings

4 - add the ability for user's to change their timezone.

 

Based on everything I am hearing, this is the way to go. I cannot convert all DATETIMEs to TIMESTAMPs, so this wouldn't be a complete fix.

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.