Friday, March 11, 2011

Demystifying Time Zones in Apps Script - Part 1

Dealing across time zones is complicated not only in real life but also in software programming. In Apps Script, we have support multiple time zones while keeping it simple. When you are writing scripts, you may have to manage time zone conversions because each service you use may operate in its own time zone.

In Apps Script, there are a few basic concepts when it comes to time zones.

  1. A script has its own independent time zone property. It does not share the time zone with either a user’s browser or a spreadsheet. A script’s time zone can be modified using the File > Properties menu in the Script Editor.

  2. A script executes in its own time zone context. Each script is guaranteed an execution environment that uses the script’s predefined time zone. For example, different scripts executing var date = new Date(); may get different dates depending on the time zone of the respective script.
Stay tuned for part 2!

Saurabh Gupta, Google Developer Relations

2 comments:

  1. Pretty amazing that I visited the Google Apps Script homepage to see if anybody else has had the same issue with time zones as I'm having right now.. and this happened to the be the first link at the top of the list! Anyway, good info. in here. Looking forward to part 2.

    ReplyDelete
  2. Thank you. Your 9 year old blog post just saved me a lot of frustrating debug time. Stupid Daylight Savings.

    ReplyDelete