We write a lot of AdWords scripts, and a recent one I was writing was for a client in Texas (Central Time Zone). The ads were going to stop displaying at a certain time, but I noticed in writing the script, the date generated for the current time was always Pacific (PDT).
After a little digging, I came to understand that even though the AdWords account time was Central, dates generated in an AdWords script are based off of the server time where the script is running. At that time, my scripts were running in a data center on Pacific time. Since data centers can move, and it’s possible the script can execute in a data center in a different time zone, it’s better to rely on your accounts time instead. Especially if you are creating a script that performs some function at a specific time, like turning on and off ads, changing copy within ads, etc.
The following are two example methods I used in order to make sure all dates were set in the same time zone. This first one just returns the current correct account time (not the server time at Google).
/** * Make sure when getting a date object, we're basing it off the account time, not the data center server time */ function getAccountCurrentDateTime() { return new Date(Utilities.formatDate(new Date(), AdWordsApp.currentAccount().getTimeZone(), "MMM dd,yyyy HH:mm:ss")); }
Or use a method like this if you want to make sure a date object your working with matches the correct time for the account.
/** * The time will convert to whatever server/data center the script is running on. Make sure the time is set to the AW account time * @param {Date} date */ function setProperTimeZone(date) { return new Date(Utilities.formatDate(date, AdWordsApp.currentAccount().getTimeZone(), "MMM dd,yyyy HH:mm:ss")); }
I hope these are helpful!