Does Google Apps Script use a funky version of EcmaScript that can't parse a date? How can I parse the date 2011-04-11T19:25:40Z
into a JavaScript Date Object in Google Apps Script?
My log output from below logs NaN
.
function showDate(){
var d = Date.parse("2011-04-11T19:25:40Z");
Logger.log(d); // <-- Logs NaN
}
Edit: /
Does Google Apps Script use a funky version of EcmaScript that can't parse a date? How can I parse the date 2011-04-11T19:25:40Z
into a JavaScript Date Object in Google Apps Script?
My log output from below logs NaN
.
function showDate(){
var d = Date.parse("2011-04-11T19:25:40Z");
Logger.log(d); // <-- Logs NaN
}
Edit: http://jsfiddle/UTrYm/
Share Improve this question edited Oct 19, 2018 at 16:16 Wicket 38.7k9 gold badges79 silver badges194 bronze badges asked Jul 13, 2011 at 18:40 citizen conncitizen conn 15.4k3 gold badges61 silver badges80 bronze badges2 Answers
Reset to default 15The format specified in section 15.9.1.15 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")
.
Google apps script works fine when you use slashes instead of dashes. Like:
var date = new Date ('2017/12/26 9:55 am');
Logger.log(date);