RE: Display Date and Time According to the Timezone
Hi Shakti,
This should be straight forward. Displaying the timezone is just adding subtracting the hours from the given timezone. For example if the date is "9/9/2918 08:00 PM" then in PST it would be date - 8 hours i.e. "9/9/2918 12:00 PM". You need to ensure that the date field in CRM is tiezone independent so that it doesn't convert any time information.
Try the below code and see if it works-
===========
var fromDate = new Date(2018,7,9,20,0,0); // get the date from crm
alert(fromDate);
var timeZone = "PST";
if(timeZone == "PST")
{
fromDate.setTime(fromDate.getTime() + (-8*60*60*1000));
alert("PST: " + new Date(fromDate));
}
else if(timeZone == "MST")
{
fromDate.setTime(fromDate.getTime() + (-7*60*60*1000));
alert("PST: " + new Date(fromDate));
}
else if(timeZone == "CST")
{
fromDate.setTime(fromDate.getTime() + (-6*60*60*1000));
alert("PST: " + new Date(fromDate));
}
else if(timeZone == "EST")
{
fromDate.setTime(fromDate.getTime() + (-5*60*60*1000));
alert("PST: " + new Date(fromDate));
}
===============
Hope this helps.