Pesky Time Zones

Time zones cause no end of confusion when you have to go from one to another. There are plenty of time converters out there on the Internet but, if you are in the middle of reading something, you don't want to go off elsewhere. So I made a little bit of JavaScript so that I could display times in whatever timezone I liked and let everyone see it in their own.

It makes use of the title attribute of HTML tags to display the time in the visitor's local time zone (actually the time zone of their computer but they are likely to be in the same place). I also use a little bit of CSS to add a small clock symbol, to the time, in the same way that Wikipedia does with external links.

The script should be fairly forgiving - it can allow 'am', 'a.m.', 'pm', 'p.m.' between the time and the time zone. It should also cover most one, three or four letter time zone abbreviations. It will return the local time in as similar a format to the one you used as it can e.g. with/without a leading zero, with/without minutes. Here are some examples for you to put your mouse over: 02:34 am ACDT, 9 am CEDT, 18 EDT, 20:09 BST, 5 pm UTC, 07:29 HAT. If you find any mistakes in the code, please let me know.

Quick HOWTO:

Download the JavaScript file and include it at the top of the HTML document body using:

<script language="JavaScript" type="text/javascript" src="timeconverter.js" />

You may want to add the following CSS in your style file (download the image):

dfn.time {
background: url("timeconverter.png") center right no-repeat;
padding-right: 13px;
}


Now you can display the time using something like:

<dfn class="time" onmouseover="UTC(this)">05:43 CDT</dfn>

Posted in astro blog by Stuart on Monday 08th Aug 2005 (19:57 UTC) | 1 Comment | Permalink

Comments: Pesky Time Zones

i found this informative and interesting blog so i think so its very useful and knowledge able.I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. In fact your creative writing abilities has inspired me to start my own word press blog now. Really the blogging is spreading its wings rapidly. Your write up is a fine example of it.

http://www.trucos-de-blackjack.com.es

Posted by blackjack en línea on Friday 03rd Apr 2009 (09:17 UTC)

ADD A COMMENT:


Don't provide an email/URL unless really necessary as your comment may get caught in the spam filter. The ground rules for commenting are:
  1. No profanity or personal attacks please. Keep it clean.
  2. Restrict comments to subjects relevant to the post.
  3. Don't mention Pluto. If you do it'll be replaced by Goofy.
  4. No spam i.e. anything commercial unrelated to astronomy.
Comments against the spirit of these ground rules may be removed.











* required fields