In the spreadsheet, need a button that writes the sheet's timezone current time and date in a cell, so everytime the button is pressed the timestamp is updated in that specific cell.
After trying different scripts, rejecting some because they don't use the format dd/mm/yyyy hh:mm:ss or do not allow the change of format, reached this point:
function TIMESTAMP() {
SpreadsheetApp.getActiveRange().setValue(new Date());
var sheet = SpreadsheetApp.getActiveSheet();
var addedDate = sheet.getRange(1,1).getValue();
var addedTime = Utilities.formatDate(addedDate, SpreadsheetApp.getActive().getSpreadsheetTimeZone(), "hh:mm a");
}
when the button, with the script, is pressed the timestamp with the correct timezone shows in the current active cell BUT an error shows up:
Exception: The parameters (String,String,String) don't match the method signature for Utilities.formatDate.
How to designate the cell where the Timestamp should show up, make its values update everytime the button is pressed and solve the parameters error?