admin管理员组文章数量:1341686
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);
本文标签: javascriptWhy does my Date object in Google Apps Script return NaNStack Overflow
版权声明:本文标题:javascript - Why does my Date object in Google Apps Script return NaN - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743598666a2508254.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论