Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First this is mostly a duplicate of <a href="https://stackoverflow.com/questions/13/how-can-i-determine-a-web-users-time-zone">How can I determine a web user's time zone?</a>, I agree with the majority vote there for this response:</p> <blockquote> <p>The most popular (==standard?) way of determining the time zone I've seen around is simply asking the user herself. If your website requires subscription, this could be saved in the users' profile data. For anon users, the dates could be displayed as UTC or GMT or some such.</p> </blockquote> <p>That being said the most common approach to automatically setting this value is to use javascript's Date <a href="http://www.w3schools.com/jsref/jsref_gettimezoneoffset.asp" rel="nofollow noreferrer">getTimezoneOffset</a>(). This can then be feed back to the server via a cookie or ajax request and stored with the user's profile, session, or cookie. </p> <p>Ultimately I still think you should allow users to change this setting so that you can determine not just the UTC offset, but the actual timezone and daylight savings information as well.</p> <p>When collecting input from users conversion to and from UTC via DateTime should suffice. DateTimeOffset is great when the client is managed code; however, with pure html/javascript it really isn't going to buy you much. Moreover the additional information of DateTimeOffset is not necessarily needed by most applications unless you intend to display to other users the originating timezone information.</p> <blockquote> <p>I feel like just trying to be diligent about manually converting every input to UTC and manually converting every view to local time display will be very error prone and lead to difficult to detect bugs where the time is not converted to or from.</p> </blockquote> <p>You should not depend upon diligence for correct date+time formatting and parsing. The .NET framework should handle this for you, for starters see "<a href="http://msdn.microsoft.com/en-us/library/bz9tc508%28v=VS.85%29.aspx" rel="nofollow noreferrer">How to: Set the Culture and UI Culture for ASP.NET Web Page Globalization</a>".</p> <p><strong>Closing remark</strong></p> <p>Frankly this is all a pain in the neck. We threw out the implementation some years ago and started transferring all date+time information in UTC, then we use Javascript to convert to local time and display format. This is really the only <em>working</em> model IMHO.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload