Reputation: 58742
I am trying to use new Internationalization API .I use chrome Version 31.0.1623.0 canary
What I want is
America/New_York
in the example)So, is it possible with the current level of support to convert between these two timezone, when
a. Daylight savings is active
//EDT: 11/2/2013 01:04:05
//UTC: 11/2/2013 05:04:05
b. Not active
//EST: 11/3/2013 01:04:05
//UTC: 11/3/2013 06:04:05
Also why is it December, when I specify month 11 in the below example.
console.clear();
var dtf = new Intl.DateTimeFormat('en-US', {timeZone: 'America/New_York'});
//EDT: 11/2/2013 01:04:05
//UTC: 11/2/2013 05:04:05
var utc1 = new Date(Date.UTC(2013, 11, 2, 5, 4, 5))
console.log(dtf.format(utc1));
console.log(utc1.toLocaleString("en-US", {timeZone: "America/New_York"}));
//EST: 11/3/2013 01:04:05
//UTC: 11/3/2013 06:04:05
var utc2 = new Date(Date.UTC(2013, 11, 3, 5, 4, 5))
console.log(utc2.toLocaleString("en-US", {timeZone: "America/New_York"}));
The output was
Console was cleared (index):21
12/2/2013 (index):29
12/2/2013 12:04:05 AM (index):30
12/3/2013 12:04:05 AM
Upvotes: 0
Views: 1487
Reputation: 12985
The javascript Date says the months are 0-11.
Daylight savings ends at 2 AM on 3 Nov 2013. So both times are within daylight savings in US Eastern time zone.
Upvotes: 1