Parsing ISO 8601 UTC dates
Here’s a concise implementation for parsing UTC date strings in ISO 8601 format into Date objects in the local time zone.
function parseIsoDate(s) {
var tokens = /(\d{4})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)\.(\d+)/
.exec(s).slice(1);
tokens[1] -= 1;
return new Date(Date.UTC.apply(null, tokens));
}
The new Date(Date.UTC.apply(null, tokens)) trick allows the direct usage of an array of date components for the construction of a new Date instance.