I am experimenting with the new Internationalization API using Chrome Version 31.0.1623.0 canary.
My goal is to:
- Convert Date Time between UTC and a specific time zone (
America/New_York
as an example). - Determine if the conversion takes into account Daylight Savings changes.
Is it possible with the current support level to convert between these two time zones when:
a. Daylight savings is in effect
//EDT: 11/2/2013 01:04:05
//UTC: 11/2/2013 05:04:05
b. Daylight savings is not in effect
//EST: 11/3/2013 01:04:05
//UTC: 11/3/2013 06:04:05
Additionally, why does the month show as December when specifying month 11 in the provided 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 displayed 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