February 2012
M T W T F S S
« Jan   May »
 12345
6789101112
13141516171819
20212223242526
272829  

Categories

Meta


« | Main | »

Javascript snack: new Date() with time zone

By Bart | February 9, 2012

To set a time, use the (very convenient) Dat eobject:

var now = new Date();

If you want to set a certain date, use:

var someDate = new Date("yyyy-mm-ddThh:mm:ss+hh:mm");

e.g.:

var someDate = new Date("2012-05-17T00:00:00+02:00");

For May 17th, 2012 00:00:00, CEST. Notice (and I just found that out), not all browsers take the same timezone when it is not supplied. To be sure, use the time zone in your date definition.

Topics: Geekstuff, Snack | Geen reacties »