Time Zones & Display Dates in a CMS

294 Views Asked by At

I have done a lot of reading on this question and I don't think it is quite as simple as it might sound.

We are building a proprietary CMS and after doing a lot of research have decided to store all dates and times in UTC (either as a unix timestamp in an INT field or as a DATETIME field).

I am completely familiar with HOW to handle time offsets etc.

Since we are storing all date/time value as UTC and converting these values to a particular timezone at the point of displaying those values:

  1. Is it common in CMS software that the display values will change if you change the website's time zone? For example, supposing you have an offset of +10 and the date displayed is therefore 1st March 2011 at 14:15; and you change the offset to -10, would the date and time displayed for that article change to 28th February 2011 at 18:15?

  2. If this is correct, what will happen if your timezone settings are obeying daylight saving time? Surely, when the timezone offset changes because of daylight saving time the dates and times of all previously published articles will also change, possible moving day or month too? I fail to see how this would be an appealing feature.

In essence, I'm asking how to enable time zone alteration of date and time without having the second effect. Or have I got the whole thing wrong?

Many thanks in advance!

1

There are 1 best solutions below

0
On

It is advisable to store all datetimestamps according to UTC.

Every time you display a date or time to the user, determine the context by using the websites global timezone setting, whatever that may be configured by the admin, or by checking what the current users timezone is. This logic is down to you to decide what is most appropriate with regards to what the date or timestamp is referring to.

This is the solution I used when developing my own CMS for a client with a warehouse in the UK who had customers in China.