<p>I have a multi-timezone web application that stores all of the datetime values in UTC in the database, when actions happen on the server, I can easily convert the time into UTC.</p>

<p>However, when a client enters a time or time span, what is the best way to detect and store it?</p>

<p>I am currently doing the following:</p>

<ol>
<li>Get the value of Date.getTimezoneOffset() (javascript) </li>
<li>Post that to the server-side code via the ICallbackEventHandler on Page.</li>
<li>Store that value in the session </li>
<li>On any subsequent request, calculate the output/input datetime value using the client's timezone.</li>
</ol>

<p>Regardless of the actual implementation, this seems like an in-elegant solution.  Does anyone have a better method?</p>

I was doing something very similar, but I now think I prefer to use
javascript
to convert all times to local on the client-side. The server will give all times in UTC in the generated page, and the
javascript
will convert it once the page loads.
This eliminates confusion on the server-side code, as I always know what time it is (UTC). On the client-side, I'm using
jquery
and the
```
each()
```
function to format all the time values at once. I write out each of the times as a
Unix
time in a hidden field to make this easy to process with
jquery
.
The only problems I see with this method is that:
a) I don't have a really good date/time formatting routine yet in
javascript
, and
b) if the user has
javascript
turned off, then it doesn't work.