0
var timezone = $A.get("$Locale.timezone");
console.log('Time Zone Preference in Salesforce ORG :'+timezone);
var mydate = new Date().toLocaleString("en-US", {timeZone: timezone})
console.log('Date Instance with Salesforce Locale timezone : '+mydate);

It displays the GMT time as ex: 2/21/2018, 8:24:08 PM I would like to convert into EST time as ex: 2/21/2018, 9:24:08 PM

Does anyone have a better way to do this? Have been trying but couldn't get it to work. Can anyone please shed some light...

2
  • Is it really displaying 8:24:08 PM when the correct time is 9:24:08 PM? If so, it's not rendering GMT, it's rendering either central time or it's a daylight savings bug. Can you please verify what string you are setting with "timezone"? Also, as a general rule when dealing with dates, don't think about converting into EST, think about converting into "America/New_York" or wherever your target is so that it auto-deals with daylight savings time.
    – jkraybill
    Feb 22, 2018 at 4:30
  • Thanks jkraybill for your response , Salesforce timezone is GMT so it's displaying it fine as GMT time, now my question is how to convert GMT into 'America/Newyork' (by keeping the general rule in mind which helps with daylight savings as you mentioned) Feb 22, 2018 at 13:27

0

You must log in to answer this question.

Browse other questions tagged .