Get today date in google appScript

后端 未结 5 1287
旧时难觅i
旧时难觅i 2021-02-01 15:48

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 = Spreadsheet         


        
5条回答
  •  借酒劲吻你
    2021-02-01 16:20

    function myFunction() {
      var sheetname = "DateEntry";//Sheet where you want to put the date
      var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetname);
        // You could use now Date(); on its own but it will not look nice.
      var date = Utilities.formatDate(new Date(), "GMT+5:30", "yyyy-MM-dd");
        //var endDate = date;
        sheet.getRange(sheet.getLastRow() + 1,1).setValue(date); //Gets the last row which had value, and goes to the next empty row to put new values.
    }
    

提交回复
热议问题