Jan 15, 2009

DateTime, UTC, and Local

Part of my work week dealt with displaying the correct date time to a distant user, based on what their settings on the site was. Microsoft provides the ability to move DateTime from UTC to local; alas, local is where the server is (in the case of webapps). This means that if my server is in the MNT timezone, I can't say "display as EST."

A workaround to this is using UTC and that commonly seen offset number (often displayed as GMT+x). Taking into account day light savings, this number added into UTC produces a user's local time, assuming you have their settings saved somewhere.

In my search for a workaround, I also wondered if the client's info would provide me their local time. This simple solution didn't reveal itself to me.

As a method of avoiding confusion about time around the globe, I'm all for "Global UTC." Most of my family are waking up for work by 7:00am MNT. I'm sure I could get them to say they wouldn't mind waking up at 2pm everyday. I just won't tell them the UTC part. *huge grin*