Introducing user specific timezones in existing high-traffic web app? -


Long story is short, we have developed a web app for internal use and one thing is moving forward for another And now it's a mother-in-law who has more than 1,000 users. The problem is that everything related to the date (which is very much!) Is hard work at Pacific Time (do not ask) and users clearly want their time zone.

I have read the best

I think the "big problem" has been estimated, which is the way to manage time zones in web applications, but right now Our current, live, mission-only that we are talking about the code of 100k + line, and possibly related to date of at least 100 different DB questions.

What I've read, it seems like to "correctly" manage the timezone to store everything in UTC and then users have to convert them to output to texas ...

But at this point there will be nothing wrong in modifying all date related queries and wrapping all the dates originally with Convert_Ties converting existing PDT timestamps into user's timezone To t?

As far as I can tell that we change all date fields in DB to UTC and convert MySQL to run the program, R. UTC will have to do this anyway, so at this point Is there any special reason to convert all existing date fields to UTC?

OK, "right" depends a lot about your application, and in your application How many dates are used In many circumstances, it is really necessary to store in UTC as well as to change the user's time zone. But not all of these

For example, if your dates are part of the recurrence pattern to schedule future events, then you will not use UTC for not .

As another example, if you have only a date-field, then the probability of those dates is "business days" that may be based on user's time zone, but it is time for your business May be based on the area.

The most common case of storage as a UTC occurs when you are referring to an immediate instant in time, such as the timestamp storage (last tension) of something in reality.

- Why not only base it on Pacific time? Well, the time of the Pacific is not fixed as UTC is it during the PTT UTC-8 in winter and UTC-7 in summer during PDT. Because of this, there is a difference of one hour per year where the local time is missing, and overlaps for one hour where the local time is repeated.

  • Create a new column in your database table for UTC time

    I can read more about this.

    Li> Type some code to adjust local time in UTC Use daylight saving time transition to add 8 hours or 7 hours to calculate UTC time. Copy the adjusted value to the new fields.

  • Manually retrieve the values ​​that fall into overlap. For Pacific Time, this DST is between the end date of 1: 00: 00.000 and 1: 59: 59.999 . You may need to manually adjust these values, because they can be either PDT or PST. To make an occupation, see if you have any other value to consider. For example, if you have an automatic incremental primary key, then sorting according to that key, timestamps must be almost sequential.
  • Now that you have a new column for UTC, then start changing all your code to use it.
  • Eventually, you can remove the old column.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -