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…

 

  1. retrieve the current, local (Eastern) timezone datetime, or…
  2. retrieve the current datetime and add 3 hours to it…

 

Thanks

Scot Rookie Asked on November 1, 2019 in SuiteScript.
Add Comment
3 Answers

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…
Rookie Answered on November 1, 2019.

This works. Additionally, I recommend the momentjs library for any handling of dates. Just makes things pretty easy.

on November 4, 2019.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.