row[0] is a date formatted such that is shows as 8/16/22 in google sheets.
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:
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]));
CodePudding user response:
As written in official documentation:
m
is minute, use M
instead.