Converting UTC Date to EST Date using Javascript

 1 Replies
 0 Subscribed to this topic
 52 Subscribed to this forum
Sort:
Author
Messages
Roger French
Veteran Member Send Private Message
Posts: 549
Veteran Member

I'm looking for how others are performing a conversion of a UTC Date (or any time zone date) to EST Date in Javascript. The requirement is to have a date/time specifically in EST timezone to write to a user business class/field.

I'm developing a IPA in Cloudsuite and at this time we are unable to have the Default Coroporate or System time zone changed to EST. 

I've already looked at a few other ways of doing this, specifically:

intlDateObj = new Intl.DateTimeFormat('en-US', {
                timeZone: "America/New_York"
            });
usaTime = intlDateObj.format(date);

And...

usaTime = date.toLocaleString("en-US", {timeZone: "America/New_York"});

But none of these are working in IPA. I could probably force the EST time by subtracting 6 hours from UTC but I want to avoid doing that.

Thanks in advance...

 

 

Ragu Raghavan
Veteran Member Send Private Message
Posts: 477
Veteran Member
I have used this to convert date_time to UTC. Maybe you can do the reverse - d = new Date(vYear,vMonth,vDay,vHour,vMin,vSec,00); diff = d.getTimezoneOffset(); //Convert to UTC so it can be compared to the dates in the LM tables N = new Date(d.getTime() + diff*60000) vUTCDate = N.getFullYear() + "" + addLeadingZeros((parseFloat(N.getMonth()) + 1).toString(),2) + addLeadingZeros(N.getDate().toString(),2) + addLeadingZeros(N.getHours().toString(),2) + addLeadingZeros(N.getMinutes().toString(),2) + addLeadingZeros(N.getSeconds().toString(),2) + "00";