Has anyone set time fields on an event? We've been...
# suitescript
b
Has anyone set time fields on an event? We've been struggling for a while, It seems to set it with the time from a date object that automatically converts to the server timezone. Defining a date with a timezone offset doesn't seem to matter (since JS just converts it). So I guess a) does that functionality seem accurate and b) any workarounds that you have seen? We have people scheduling events in a variety of timezones and so it gets super confusing.
m
From what I understand on time fields, if you're pulling the value from the netsuite field it will come through as Pacific time. If you create a new Date using pure js it will be the local time zone. You can use format.format to set a specific timezone
b
setting dates and times in suitescript means understanding timezones
netsuite has 2 representations for dates, a Date object and a string
keep in mind that a Date represents a unix time offset
that unix time has multiple string representations, all of which can represent the same unix time
its true that the Date object by default will choose a pacific timezone representation when you log it
there are a bunch of methods to manipulate the date, but your only choices will be to manipulate it in pacific timezone or utc timezone
if you are trying to manipulate it in another timezone, my recommendation is to use moment-timezone
once you have the Date the way you want it, you use Record.setValue to set the value with your Date
an alternative is to use Record.setText, which accepts the string as the text
you usually want to use format.format to generate that string
b
Thank you both for your ideas, sorry it's taken me all day to respond. setText I think is the magic solution. I've done a bunch of date fields and those aren't horrible, it was this time field that was screwing me up. With setText though I was able to set a string and it accepted it as the current user's timezone. Just trying to make some final sense of how it's processing the string