Skip to main content

Notifications

Announcements

No record found.

Customer Service forum

Display Date and Time According to the Timezone

(0) ShareShare
ReportReport
Posted on by 932

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:
  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Display Date and Time According to the Timezone

    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.

  • RE: Display Date and Time According to the Timezone

    I want time like a clock moving

  • RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Display Date and Time According to the Timezone

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

  • RE: Display Date and Time According to the Timezone

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

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Display Date and Time According to the Timezone

    Yes.

  • RE: Display Date and Time According to the Timezone

    Is it work like a clock?

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    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.

  • RE: Display Date and Time According to the Timezone

    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
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: Display Date and Time According to the Timezone

    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]

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

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,711 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans