Introduction to UTC Dates
var offset=-8; //offset from UTC
var luckyday=new Date(Date.UTC(2008,7,8,(20 + offset ),8);
document.write(" The 2008 Olympics starts at " + luckyday.toUTCString());
document.write(" In local time this is " + luckyday.toLocaleString())
Note: In the example above, I converted from Beijing time to UTC by adding the offset from UTC ("-8") to the Beijing time - this is why argument 4 of Date.UTC reads "(20 + offset)" above.
Date.UTC( year, month[, day, [hour, [minutes, [seconds, [milliseconds]]]]])
converts the given date into milliseconds since January 1, 1970.
U.S. Naval Observatory. "What is Universal Time?." 30 October 2003. U.S. Naval Observatory, Astronomical Applications Department. 6 July 2007. <http://aa.usno.navy.mil/faq/docs/UT.html>
This site needs an editor - click to learn more!
You Should Also Read:
Editor's Picks Articles
Top Ten Articles
Content copyright © 2018 by Julie L Baumler. All rights reserved.
This content was written by Julie L Baumler. If you wish to use this content in any manner, you need written permission. Contact BellaOnline Administration for details.