StorageB / Google-Sheets-Logging

Log data from an ESP8266 device directly to Google Sheets without a third party service. Log sensor data, send data by pressing a button, and receive data from a Google spreadsheet. (NodeMCU, Wemos D1 mini, Adafruit Feather HUZZAH, etc)
145 stars 32 forks source link

How to change the time zone. #13

Closed Aly024 closed 1 year ago

Aly024 commented 1 year ago

I tried GMT+6 instead of CST but it is not working

https://github.com/StorageB/Google-Sheets-Logging/blob/7d850ee341723d698ef9fa0ded3b66a63fd62956/GoogleScripts-example.gs#L34

StorageB commented 1 year ago

Instead of using CST or GMT-6 notation, use the Google Timezone ID as documented here: https://developers.google.com/google-ads/api/data/codes-formats#timezone-ids

For the Central timezone, you would have:

var date_now = Utilities.formatDate(new Date(), "America/Chicago", "yyyy/MM/dd"); // gets the current date
var time_now = Utilities.formatDate(new Date(), "America/Chicago", "hh:mm:ss a"); // gets the current time
Aly024 commented 1 year ago

I was able to solve it. Both method works. I have to deploy it as a new version and then run the app script