简体   繁体   中英

Wrong Time Zone in logs of Google Apps Scripts

The Time Zone get from Date() in the script is correct, CEST (Central European Summer Time). But the time zone reported from View -> Logs menu in the script editor is PDT (Pacific Daylight Time)

That happens whatever standalone scripts and spreadsheets scripts.

This is an ad-hoc example code:

  Logger.log(Session.getActiveUserLocale());
  Logger.log(Session.getScriptTimeZone());
  var d = new Date();
  Logger.log(d.toLocaleString());

[17-09-12 01:50:46:566 PDT] es

[17-09-12 01:50:46:567 PDT] Europe/Paris

[17-09-12 01:50:46:568 PDT] 12 de septiembre de 2017 10:50:46 CEST

The Time Zone of the system is CEST. The Time Zone in Google Calendar and GMail of the google account is CEST too.

Any explanation?

PS

Related but not the same issue that theese questions:

The log & the execution transcript seem to use US/PDT, which would be consistent with Google's home time-zone. However, if you export the logs the times are rendered in the script time-zone. Here's an example from a script that emails me an execution log.

Logs from Script Editor View > Logs

[17-09-12 18:28:40:915 PDT] Export file created: '[redacted].csv' (id: [redacted])
[17-09-12 18:28:43:274 PDT] Archive file created: '[redacted] - 20170913112841+1000 - export.csv' (id: [redacted])
...etc, etc.

Same section of the log from the emailed transcript:

Wed Sep 13 11:28:40 AEST 2017 INFO: Export file created: '[redacted].csv' (id: [redacted])
Wed Sep 13 11:28:43 AEST 2017 INFO: Archive file created: '[redacted] - 20170913112841+1000 - export.csv' (id: [redacted])
...etc, etc.

Annoyingly, while the exported logs are in the correct tz, they're in that non-ISO format Google so likes to foist on us.

Go to 'File > Project properties > Info tab' and set the timezone.

If you can't see the menu bar with 'File' etc, you're using the new editor. You will need to click 'Use legacy editor' which will let you access the setting, then you can go back to the new editor.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM