0

Recently it came to our attention that our DB was using multiple timezones to record data, and or pass data around, and because of that data started going out of sync. So recently we made some changes to the data (accepting that some of the time data will be misleading or corrupt in the sense that its not 100% accurate. (well the old stuff at least)) That said, we have started making everything we can use GMT as times in/out the problem is now trying to use offsets according to a user defined offset from a predefined list.

So I can query accordingly and display it back to the user accordingly. Lets say I have a user from western america in the pacific time zone, that is an offset of -8, where as if I have someone in the eastern time zone thats a offset of -5

With that dates in and out are currently based on the user preference, where as everything is stored in GMT on the DB so how is it I can pass -N accordingly to something like gmdate() so I can query properly and display properly? I hope this makes sense to someone.

chris
  • 36,115
  • 52
  • 143
  • 252

1 Answers1

0

You can't just expect time zones to be a fixed number of hours apart. First off, daylight savings will break that notion, but asides from that, there are a few time zones that aren't hour aligned.

Take a look at this post:

How do you handle timezone difference calculation in PHP?

(There are many similar questions on stackexchange.)

You may want to take a quick look at falsehoods programmers believe about time and a followup with more falsehoods regarding time zones.

Community
  • 1
  • 1
mzedeler
  • 4,177
  • 4
  • 28
  • 41