Reputation: 410
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:
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
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
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