Skip to main content

D365 portal date field formatting

 In portal the CRM form date field is not showing in to the right format. it shows like this.



If you want to format this date field you can use this script.

  function setDateTimeFieldValue(fieldId, dateValue) {  
   //Get the submit field  
   var $submitField = $("#" + fieldId);  
   //Get the display field  
   var $displayField = $submitField.nextAll(".datetimepicker").children("input");  
   //Get the display date format  
   var dateFormat = $displayField.attr("data-date-format");  
   //Set the submit field. Remember this needs to be in UTC and the format must be exact.  
   $submitField.val(moment.utc(dateValue).format("YYYY-MM-DDTHH:mm:ss.SSSSSSS"));  
   //Set the display field using the page's date format  
   $displayField.val(moment(dateValue).format(dateFormat));  
 }  
Call this function with field name and value


 var std__eventstartdatetime = setDateTimeFieldValue('std__eventstartdatetime',data.value[0].std__eventstartdatetime);  

Now your date field will be look like this format.




Comments