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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Change the time format

(0) ShareShare
ReportReport
Posted on by 958

How we can change the time format from 24 hrs to 12 hrs with am and pm and date format should be in dd:mm:yyyy?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Shakti ,

    Go to Settings --> Administrator --> System Settings -->Go to Formats tab -->Click on Customize --> Go to time tab and set H or HH.

    timeformat.png

  • Shakti Singh Rajput Profile Picture
    958 on at

    I am using this code to store the escalation blog and it this date and time formate is not correct and i apply the changes as mentioned above das's post but it is not worked also.

    function saveEscalate()

    {

       var check =  Xrm.Page.getAttribute("new_caseesclated").getValue();

       var log = Xrm.Page.getAttribute("modifiedon").getValue();

       if(check == true)

       {

           alert(check);

           var today = new Date();

           var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();

           var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();

           alert(date+" "+time);

           Xrm.Page.getAttribute("new_escalatedblog").setValue(log+"\n"+date+" "+time);

       }

       else

       {

       }

    }

  • Suggested answer
    Justinjose Profile Picture
    2,707 on at

    Hi Shakthi,

    Try below Script

    function saveEscalate()
    {
       var check =  Xrm.Page.getAttribute("new_caseesclated").getValue();
       var log = Xrm.Page.getAttribute("modifiedon").getValue();
       if(check == true)
       {
           alert(check);
           date =new Date();       
           var hours = date.getHours();
           var minutes = date.getMinutes();
           var day = date.getDate();
           var month = date.getMonth()+1;
           var year = date.getFullYear();
           var ampm = hours >= 12 ? 'pm' : 'am';
           hours = hours % 12;
           hours = hours ? hours : 12; // the hour '0' should be '12'
           minutes = minutes < 10 ? '0'+minutes : minutes;
           var strTime = hours + ':' + minutes + ' ' + ampm;
           var fullDate = day+"/"+month+"/"+year;
           alert(strTime +""+day+"/"+month+"/"+year);
           Xrm.Page.getAttribute("new_escalatedblog").setValue(log+"\n"+fullDate+" "+strTime);
          }
          else   
          {   
          }   
       }


    Thanks

    Justin Jose

  • Suggested answer
    Shahbaaz Ansari Profile Picture
    6,211 on at

    Hi Sakti,

    Please check below code,

    function saveEscalate()

    {

      var check =  Xrm.Page.getAttribute("new_caseesclated").getValue();

      var log = Xrm.Page.getAttribute("modifiedon").getValue();

      if(check == true)

      {

       var today = new Date();

    var dd = today.getDate();

    var mm = today.getMonth()+1;

    var yyyy = today.getFullYear();

    var hours = today.getHours();

    var minutes = today.getMinutes();

    var ampm = hours >= 12 ? 'pm' : 'am';

    hours = hours % 12;

    hours = hours ? hours : 12; // the hour '0' should be '12'

    minutes = minutes < 10 ? '0'+minutes : minutes;

    var strTime = hours + ':' + minutes + ' ' + ampm;

    if(dd<10)

    {

    dd='0'+dd;

    }

    if(mm<10)

    {

    mm='0'+mm;

    }

    today = dd+'/'+mm+'/'+yyyy + ' '+ strTime;

       Xrm.Page.getAttribute("new_escalatedblog").setValue(today.toString());// make sure this is text field

      }

      else

      {

      }

    }

    Thanks,

    Shahbaaz

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Shakti ,

    Check user settings instead of system settings. Go to top corner gear icon --> options -->Go to Formats tab -->Click on Customize --> Go to time tab and set HH :mm , it will work.

  • Suggested answer
    Vipin J Profile Picture
    1,603 on at

    Refer here for scripting 

    How to format Date and Time with AM / PM

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans