RE: SuiteScript 2.0 local DateTime or DateTime Math
My server is in the Northwest region but our corporate office is on the east coast…
I need to be able to record a datetime within a suitescript 2.0 scheduled script.
How can I either…
- retrieve the current, local (Eastern) timezone datetime, or…
- retrieve the current datetime and add 3 hours to it…
Thanks
I found the answer I needed….
Since I know that my server time is Pacific and I am always 3 hours ahead in Eastern, even with Daylight Savings Time…
var date = new Date();
date.setHours(date.getHours() + 3);
…which gets the current hours of the variable date and sets it to +3 hours…
Although this particular script should never run after 9pm, from what I have read, if the above “+3” returns an hour over 23, it will increment the date and the extra hours so it should be valid for any time reference…
This works. Additionally, I recommend the momentjs library for any handling of dates. Just makes things pretty easy.