Get today date in google appScript

后端 未结 5 1286
旧时难觅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条回答
  •  闹比i
    闹比i (楼主)
    2021-02-01 16:08

    Utilities.formatDate(new Date(), "GMT+1", "dd/MM/yyyy")
    

    You can change the format by doing swapping the values.

    • dd = day(31)
    • MM = Month(12) - Case sensitive
    • yyyy = Year(2017)
    function changeDate() {
        var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(GA_CONFIG);
        // You could use now Date(); on its own but it will not look nice.
        var date = Utilities.formatDate(new Date(), "GMT+1", "dd/MM/yyyy")
        var endDate = date
    }
    

提交回复
热议问题