Reputation: 43
How can I define the format in which I want the timestamp?
For instance, it currently uses
var timestamp = new Date();
var ss = SpreadsheetApp.getActive();
var timezone = ss.getSpreadsheetTimeZone();
var timeString = Utilities.formatDate(timestamp, timezone, 'HH:mm');
var dayString = Utilities.formatDate(timestamp, timezone, 'EEE');
var start = appendRowsToArchiveSheetSettings.timeLimits.startTime;
var end = appendRowsToArchiveSheetSettings.timeLimits.endTime;
var days = appendRowsToArchiveSheetSettings.timeLimits.days;
if ((start && timeString < start) || (end && timeString > end) || (days.length && days.indexOf(dayString) === -1)) {
return;
}
It gives the timestamp in the following format - m/dd/yyyy hh:mm:ss
I want the format as dd/mm/yyyy hh:mm:ss
What can I do here?
I tried the following snippet to get the current date from the active sheet and show it in the specified format.
const DATE = SpreadsheetApp.getActive();
const FormattedDATE = Utilities.formatDate(DATE, "GMT", "EEEEE, dd MMMM yyyy");
Getting the following error - Exception: The parameters (SpreadsheetApp.Spreadsheet,String,String) don't match the method signature for Utilities.formatDate.
Upvotes: 0
Views: 314
Reputation: 64062
Creating a timestamp:
function myfunk() {
var ss = SpreadsheetApp.getActive();
var ts = Utilities.formatDate(new Date(),ss.getSpreadsheetTimeZone() "dd/MM/yyyy HH:mm:ss");
return ts;
}
Note this return a string not a date.
Upvotes: 1