Home > Blockchain >  Two apps script projects outputting different toLocaleTimeString() (en-US PT & Eastern)
Two apps script projects outputting different toLocaleTimeString() (en-US PT & Eastern)

Time:02-24

I'm working on a timesheet for my office and I've ran into the last problem I'd expect; the locale in one sheet (used for the business's main operations) is different than the locale in the other (going to be used for clocking in and out).

I know how to get the correct time output despite the problem, but I don't know why it's a problem in the first place.

None of the code in my first sheet (the correct locale) is relevant; that project has little to do with time and date.

The code for my second sheet is doing a few things:

  1. Use the start day & end day of a week to determine which sheet to use in the spreadsheet (sheets are split into weeks)

  2. get the current date & user's name to determine the position of the clock-in time input

Pretty simple

So far I've tried using Test function to display the issue. The left log is correct.

CodePudding user response:

This was solved by the first comment.

To fix this issue, first check the following box in Apps Script Project Settings:

Show "appsscript.json" manifest file in editor

Then just update the "timezone" object literal to whichever timezone you're working with.

Here is a list of timezones

  • Related