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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Change date format with custom javascript code

(0) ShareShare
ReportReport
Posted on by 2

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

I have the same question (0)
  • Suggested answer
    SCV Profile Picture
    1,004 on at

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

  • Suggested answer
    AbhiCode Profile Picture
    492 on at

    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

  • Goutham A Profile Picture
    2 on at

    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
    Goutham A Profile Picture
    2 on at

    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;

    }

    }

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans