How To Set the Date Format in MDM Search Columns
DCM leverages the momentJS library to render the Date fields. You can find the moment.js format codes here: https://momentjs.com/docs/#/displaying/format/
Setting a Predefined Date Format
- Open the Search Builder.
- Select the Date field you need to configure a Date render.
- Select the Edit action for the Date field. In our example, we chose the Created Date field for simplicity.
- Expand the dropdown list for the Date Format property (1), and select any pre-configured format (2). In our example, we select the Full DateTime ("dddd, MMMM Do YYYY, h:mm:ss a").
- Apply the changes to the property.
- Save the search and do a Preview to validate the format.
Setting a Custom Date Format
- Open the Search Builder.
- Select the Date field you need to configure a custom Date render.
- Select the Edit action for the Date field. In our example, we chose the Modified Date field for simplicity.
Insert the following code in the Custom Renderer property.
function (value, metaData, record) { var dateFormat = 'MM dd hh', v_date = new Date(value); return moment(v_date).format(dateFormat); }
JSApply the changes to the property.
Save the search and do a Preview to validate the new Date format render.
Setting a Relative Time Date Format
- Open the Search Builder.
- Select the Date field you need to configure a custom Date render.
- Select the Edit action for the Date field. In our example, we chose the Due Date field for simplicity.
Insert the following code in the Custom Renderer property.
function (value, metaData, record) { v_date = new Date(value); return moment(v_date).toNow(); }
JSApply the changes to the property.
Save the search and do a Preview to validate the new Date format render.