web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Customer Service forum

Display Date and Time According to the Timezone

(0) ShareShare
ReportReport
Posted on by 958

Scenario is that I wan to show the Date and Time according to the selected Timezone. I have four timezone mentioned below. 

    • PST (Like for PST when i select this Another date and time field should be display: -{1:25 AM/ Thursday, 9 August 2018Pacific Time (PT} )
    • MST
    • CST
    • EST
Categories:
I have the same question (0)
  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

    do you means on form ? if yes, you cant do it via out of box, because date format follow the personal setting.

    But you can achieve it via unsupported JS code, which i am not recommended to do it.

    [View:https://community.dynamics.com/crm/f/117/t/231608:750:50]

  • Shakti Singh Rajput Profile Picture
    958 on at

    Thanks for help!!

    Basically i have a field type of Option Set which has above 4 different Timezone value and if i select any one of them then display the date accoding to that time zone.

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    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.

  • Shakti Singh Rajput Profile Picture
    958 on at

    Is it work like a clock?

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Yes.

  • Shakti Singh Rajput Profile Picture
    958 on at

    Means after implement time will be continueously going on like a clock.

  • RaviKashyap Profile Picture
    55,410 Moderator on at

    No, The shared sample script will convert the time from your date time field to selected timezone.

  • Shakti Singh Rajput Profile Picture
    958 on at

    I want time like a clock moving

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi Shakti,

    Though you initially asked for the logic to show the time based on timezone, you cn  check the below article for timer control which may help you achiev your requirement.

    www.inogic.com/.../adding-timer-control-to-lead-entity-in-dynamics-crm-2013-spring-release

    Hope this helps.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Season of Giving Solutions is Here!

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Customer Service

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans