ekrembk
ekrembk

Reputation: 410

Handling Multi Timezone

I'm developing a new web app which will be used in many countries -and timezones-. There are questions about this problem but not consensus.

I store all time records in UTC. So the problem is printing. I'm developing with PHP so I know that PHP can't see local timezone. Which gives us some choises:

  1. Printing it as is and changing on the client side.
  2. Javascript trick to tell the timezone first time, and server remembers it from then.
  3. Locating from IP. How sure can we be with this?
  4. Telling user to choose timezone which is the easiest and ugliest way. UX, please!

Any option has pros and cons. I would like to read your choises and any information you know or thoughts about this topic. How others does that, tips etc. Any answer is appreciated.

Thank you.

Upvotes: 1

Views: 127

Answers (2)

Mike Samuel
Mike Samuel

Reputation: 120516

Printing it as is and changing on the client side.

I've had good experiences with this.

I markup my dates using the date-time microformat

<abbr class="dtstart" title="2012-08-15T12:00:00.00Z">2012-08-15 at noon</abbr>

and then have some javascript which just finds all those and reformats them.

Upvotes: 2

Fluffeh
Fluffeh

Reputation: 33522

The best approach is a combination of the above.

Use option 2, from the start. It should give you the right data in a pinch assuming their PC is set to the right time. However, option 3, allowing then user to confirm really is a must. When the user creates an account, let them pick their timezone and show them the time they are picking. This will be much more accurate, relies less on javascript (many folks turn it off) and some users may well want to see the data in a timezone different to what they are currently in - travelling salesman for example?

Changing it client side isn't really great - and again will need javascript which can be unreliable. Getting the timezone from an IP can be a pain, also unreliable and easily overcome by the suggestions above.

Upvotes: 1

Related Questions