MrDave's (David Yack) WebLog

From one TimeZone to the next...

So is it just me or is it hard to find a good design pattern for handling user time zone differences in ASP.NET?

For conversation sake - your server is in mountain time and stores a record with 5pm

User in central time visits your site and sees it as 5pm, but that's really 6pm central.

What you really want to do is show the user 6pm!

So back to my original question - is there not a good design pattern for handling time zone differences?

Comments

Oddur Magnusson said:

I guess you have to do it client side, because you have no way of knowing for sure what timezone the asp.net is coming from. I think javascript is your best bet here :(
# December 6, 2003 10:02 PM

Me said:

As I see it there are two common cases:

1. Times generated on the server (e.g. time an order was received). In this case you use the timezone of the server (if storing in a database you may want to convert to UTC). To display the time to users display with an explicit timezone (e.g. "11:00 AM EST"), possibly allowing users to specify their preferred timezone for display (e.g. ASP.NET forums allows users to specify their preferred timezone in a profile).

2. Times entered by the user (e.g. a calendar application). If you know the users timezone you can treat it like 1 above. If not, you should store and display it without timezone information.
# December 7, 2003 6:19 AM

Husain said:

I generally store time in GMT format (I live in Asia). I also store user preferred timezone as a positive or negative integer - referring to the number of hours the user is ahead or behind GMT. So if a user has specified the timezone, adjusting the time accordingly is simple maths. I also display a note at the foot of every page specifying that the time has been adjusted. Something like: "All times are GMT + 4".
# December 7, 2003 7:28 AM

julie lerman said:

Take a look at Clemens Vasters blog. I know he was talking about this a few months ago - not patterns per se, but problems and solutions. http://staff.newtelligence.net/clemensv/
# December 7, 2003 9:16 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)