language agnostic - How to display local time of the browser in a web app -


I am writing a web app and I would like to display the timestamp on the page in the user's local time. There are several ways to do this, but it is not clear what is a good way.

  1. Use the geographic location from the IP address to get the time zone - it seems like too much land. / Li>
  2. Use Javascript to provide date time on the page - it looks like complex client-side javascript.
  3. Use javascript to retrieve timezone and locale with user preferences, and save it In a cookie, the server can use it to format this date, the server side code is good, but the first page There is not a great way to get it for load.
  4. Any options for the http request titles? which one? How reliable are they in all browsers?

Any advice to apply it well?

try me This converts UTC timestamp into fuzzy time phrases (Like "about 2 hours ago").

You output HTML like this:

  & lt; Abbr class = "timgo" title = "2008-07-17T0 9: 24: 17Z" & gt; July 17, 2008 & lt; / Abbr & gt;  

And the plugin turns into something like this:

   

Using a little jQuery in this way:

  jQuery (document) .ready (function () {jQuery ('abbr.timeago'). ();});  

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -