how to change timezone in googlesheet?

前端 未结 1 1947
日久生厌
日久生厌 2021-01-23 16:25

I have copied a script for: when you visit an url, with values ​​in the url: my googlesheet automatically fills with the values ​​hidden in the url in cell and on the same lin

相关标签:
1条回答
  • 2021-01-23 16:49

    There are two ways for changing the time zone in your Spreadsheet. The first one is through the UI and the second one is programmatically.

    The first way -> From User Interface

    Go to File -> Spreadsheet settings, a pop-up window will open as in the next image:

    As you can see there's one option to change the time zone to the one you desire.

    The second way -> Programmatically:

    The Spreadsheet Class has the setSpreadsheetTimeZone(timezone) method, which will change the time zone in the Spreadsheet, but now programmatically. This is a little example of how using it:

    function dateFormat() {
      var ss = SpreadsheetApp.openById("your-id");
      // Get the current Spreadsheet's time zone 
      var currentTimeZone = ss.getSpreadsheetTimeZone();
      Logger.log(currentTimeZone); // Check the current time zone
      // Set the new Spreadsheet's time zone
      var updatedTimeZone = ss.setSpreadsheetTimeZone("Europe/Paris");
      Logger.log(updatedTimeZone); // Check the updated time zone
    }
    
    0 讨论(0)
提交回复
热议问题