Google Apps Script Formatdate Using User's Time Zone Instead Of Gmt
I have a line that sets the current date and time in a cell: sheet.getRange(1,1).setValue(new Date()); Then I have a line that creates a formatted date based on that cell's value
Solution 1:
You can directly get the spreadsheet Time Zone like this :
var addedDate = sheet.getRange(1,1).getValue();
var addedTime = Utilities.formatDate(addedDate, SpreadsheetApp.getActive().getSpreadsheetTimeZone(), "hh:mm a");
See doc here
but Google Apps Script uses these formats if you want to choose it yourself :
Post a Comment for "Google Apps Script Formatdate Using User's Time Zone Instead Of Gmt"