citizen conn citizen conn - 1 year ago 107
Javascript Question

Why does my Date object in Google Apps Script return NaN

Does Google Apps Script use a funky version of EcmaScript that can't parse a date? How can I parse the date

into a JavaScript Date Object in Google Apps Script?

My log output from below logs

function showDate(){
var d = Date.parse("2011-04-11T19:25:40Z");
Logger.log(d); // <-- Logs NaN


Answer Source

The format specified in section is YYYY-MM-DDTHH:mm:ss.sssZ so maybe try adding milliseconds to your date format as in Date.parse("2011-04-11T19:25:40.000Z").

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download