I have a content search webpart on my SharePoint site, which I use for announcements. I would like it to show the date and time of creation, so I added a mapping that shows the date and time (see screen shot below) but the format is unfortunately not very good looking. How do I change the time format?

enter image description here

enter image description here

1 Answer 1


You could create a copy of the Content Search Web Part Display Template that you wanna use.

In the current site collection, go to Site Settings > under "Web Designer Galleries", click "Master pages and page layouts" > Display Templates > Content Web Parts > download a copy of "Item_Picture3Lines.html"

Open the file in notepad, notepad++ or any other text editor and change the Title so you can differ this display template from the others. A example can be <title>Custom Picture on left, 3 lines on right</title>

Scroll down to row 63 and find the following:

var line1Id = encodedId + "line1"; var line2Id = encodedId + "line2"; var line3Id = encodedId + "line3";

After these lines, add

var parseDate = new Date(line3.inputValue);
var line3Date = parseDate.format('ddd MMMM d HH:mm:ss');

keep scrolling down to row 113 and look at the end of the row before the closing div tag. Change _#= line3 =#_ to _#= line3Date =#_. Save the file as the same name you used on row 3.

Upload the HTML file to the same location from where you downloaded it. When the file has been uploaded, a javascript file should be created with the same name. Publish a major version of the HTML file and go back to the site where your content search web part is located.

Edit the web part properties and your new display template should show up under "Item". Select it and then change the property mappings, set "Created" or "DateCreated" in Line 3. Apply and save the page.

enter image description here


You could take the easy way, by just creating a calculated column based on the Created column, or in your case DateCreated with the following formula:

=TEXT(Created, "ddd MMMM d HH:mm:ss")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.