How to Change the Timezone of Your Apps Script

Learn how to change the timezone of your Apps Script to ensure it aligns with user settings, avoiding potential issues with timestamps across different sheets and users.

So you want to change the time zone of your Apps Script . This is very different than the time zone of your spreadsheet . In Apps Script , Extensions, Apps Script , we'll go over here. Sometimes we're dealing with time stamps, and especially in something like Utilities. FormatDate. We have a date, we have a time zone , and we can hard code this time zone , but We're going to run into problems if we are ever duplicating this to another sheet, another person, another department, or even trying to sell an Apps Script or some sheet, and this time zone is not the same as the user. So what we can do is we can say session. getScriptTimeZone. But this time zone is set here in the Apps Script. It is not in the sheet itself. How To Change Date Format Automatically Every Locale Listed in Google Sheets and a Tool to Save Your Sanity How do I reference a different spreadsheet in Apps Script? TWO SHEET TIMEZONES

And this time zone is over here on the left. Click on project settings, and here in general settings, this time zone , you have to select the very particular time zone you're in or the user is in. Here we'll set it to Boise. And that is it. It is saved. Once you've changed it, you can go back to your editor , and you can use this session. getScriptTimeZone anywhere in your script to get the time zone that the sheet is in. Hopefully this is helpful for you. If you're looking to get more out of Google sheets than you ever have before, consider subscribing here on YouTube to better sheets. Every Locale Listed in Google Sheets and a Tool to Save Your Sanity Every Locale Listed in Google Sheets and a Tool to Save Your Sanity From Sheet to Script And Back Again - Learn to Code In Google Sheets Part 3 How to Change Time Zone in Google Sheets