Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Change date format with custom javascript code

Posted on by

Hi,

I need to change date format of certain data time fields in my current application. Can this be acheived by javascript?

For some text fields which display date, i am able to manipulate and display in my desired format. But for date time fields i could not.PLease help

Thanks

*This post is locked for comments

  • Suggested answer
    Goutham A Profile Picture
    Goutham A on at
    RE: Change date format with custom javascript code

    I have found one unsupported way of doing this(although not suggested).

    All date formats are rendered in page with specific class.Just get all elements with that class and convert appropriately. Please note that u do null checks wherever required.

    var dateformatDivs = $('.ms-crm-data-format-string')

    for(var i=0;i<dateformatDivs .length;i++)

    {

    var date=  new Date(dateformatDivs [i].innerHTML);

    if(date != null)

    {

     date = formatDate(date);

     dateformatDivs[i].innerHTML = date;

    }

    }

  • Goutham A Profile Picture
    Goutham A on at
    RE: Change date format with custom javascript code

    Thanks Abhishek

    I have  lot of date time fields and  metadata cannot be changed now. IS there any other way or else i can say it as not feasible

  • Suggested answer
    AbhiCode Profile Picture
    AbhiCode 492 on at
    RE: Change date format with custom javascript code

    Hi Goutham,

    In Dynamics, there are no support dates that don't have format specific. I really wish they did sometimes about date format.

    For Some of the fields: One way you can it is to have a date field for the actual date, and a text field for the specific format MM/YYYY display value. Anytime you need to set the date you would have to set the actual date field, but a JavaScript would set your text field to the formatted value. 

    For Full organization: Settings --> Admin --> System Settings -->Formats -- > Choose current format as "Arabic (U.A.E)"

    3733.3.PNG

    Hope this helps, if so, I would appreciate if you would mark this as the verified answer.

    Thanks

    Abhishek Bhansali

    Read My Blog

  • Suggested answer
    SCV Profile Picture
    SCV 1,004 on at
    RE: Change date format with custom javascript code

    DateTime fields use the format set under personal settings. You can't change it via javascript.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans