[英]Utilities.formatDate() returning month as 0
row[0] is a date formatted such that is shows as 8/16/22 in google sheets. row[0] 是一个日期格式,在谷歌表格中显示为 8/16/22。
And for the code,对于代码,
var date = Utilities.formatDate(new Date(row[0]), SpreadsheetApp.getActiveSpreadsheet().getSpreadsheetTimeZone(), "m/d/yy");
SpreadsheetApp.getUi().alert(date);
I expected the output of 8/16/22 but instead get the following:我预计 22 年 8 月 16 日的 output 但得到以下结果:
My end goal is to have this date be pasted into a google doc template using the following line:我的最终目标是使用以下行将此日期粘贴到谷歌文档模板中:
body.replaceText('{{date}}', date);
And here is the output of just SpreadsheetApp.getUi().alert(new Date(row[0]));
这是
SpreadsheetApp.getUi().alert(new Date(row[0]));
As written in official documentation :正如官方文档中所写:
m
is minute, use M
instead. m
是分钟,请改用M
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.