0

im just learning google app script, and this problem really puzzling me. so, pretty please some help.

so, i am have this Google Sheet that collects responses from Google Form. This form has "Date" response on it, so i assume i always get the correct date format since it is automaticly generated ny sistem. But when i take the value in google app script, in

(DataObject[4].getDate()).toString()

it return yesterday value. so, if the value in Google sheet written "4/8/2022" i get "7" value in script app, instead of "8". (DataObject[4] is the variable where i store date value)

i already tried to add +1 in the script, like in

(DataObject[4].getDate()+1).toString()

but i got problem when the real date is "4/1/2022" the value become "32" (since march have 31 days).

is there something i did wrong?

Rubén
  • 34,714
  • 9
  • 70
  • 166

1 Answers1

2

You have to change timezone in your script editor.

Click o the gear on the left hand side of the script editor and check the third box enter image description here

Go back to the script, choose appsscript.json and change timezone as needed, for instance enter image description here

Mike Steelson
  • 14,650
  • 2
  • 5
  • 20