How do I get the Today date on google appscript?
I need to write a code to input today´s date in a cell.
function changeDate(){
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(GA_CONFIG);
var date = //Today´s date!?!?!!?
var endDate = date;
sheet.getRange(5, 2).setValue(endDate);
}
The
Date
object is used to work with dates and times.Date objects are created with
new Date()
now - Current date and time object.
Google Apps Script is JavaScript, the date object is initiated with
new Date()
and all JavaScript methods apply, see doc hereThe following can be used to get the date:
You can change the format by doing swapping the values.