Hey guys, does anyone know how to use setValue() o...
# suitescript
c
Hey guys, does anyone know how to use setValue() on a server side script with a date field when I need to utilize a specific timezone?
b
date fields tend not to have that precision
the Date object you get from getting a date field represents a date at 12 am in the current user's timezone
c
sorry I meant the datetime field
when I create a new Date() on the server, it is not the same timezone as we have configured in the company
b
new Date will be in pacific timezone
the date time displayed will be in the current user's timezone
c
I’m not talking about what is displayed, I’m trying to persist the correct datetime to the database
b
not how a date time works
change the current user's timezone will change the display value of the date time
will still represent the same unix time
c
Not what I’m saying
I want to pass, via a POST call, the current datetime including timezone
and then save it to the database as whatever the unix equivalent is
b
then you want to parse the datetime from your post
honestly you dont want to parse the datetime and want to start from the unix time
but if have you to parse, use Moment Timezone
c
Thanks I will take a look
s
If you pass a complete ISO8601 date with full timezone and create a
Date
instance in your script I think the correct timezone will flow to the DB
b
be careful on that one, thats one of the things 2.1 can do that 2.0 wont
👍 1
s
Do you know if that's a JS spec difference or rather a runtime difference between 2.0 and 2.1?
b
runtime is allowed to choose how it parses dates
later javascript versions tightened the specs
so i guess both
c
I decided to pass the epoch # and use that, so it shouldn’t matter what timezone the server is