0

We have a standard Calendar app in SP2013 with some events that we roll up on a homepage using a content search web part (the Two Lines display template). We show two properties: the title and the start date of the event. The latter one is a managed property mapped to "EventDate". See screenshot.

It shows this property on the homepage as follows: "6-5-2015 07:00:00". How can I remove the seconds part (so the last two :00's) from the time notation? (because it's irrelevant to the user).

Can I change this in the Search Schema or does it require a code change in the display template? If it's code, please be specific and detailed as I'm not a developer. Your help would be appreciated! :)

By the way: perhaps handy to know: region settings of the site are as follows:

timezone: UTC+01:00 Amsterdam (which is correct)
country: Netherlands
time format: 24 hours
standard language: Dutch

enter image description here

  • Je vraag staat nog steeds als onbeantwoord in de lijsten, mogen we 'm afsluiten? – Danny '365CSI' Engelman Jan 14 '16 at 12:16
  • yes, mag afgesloten worden. – Piet Schat Jan 14 '16 at 13:42
  • Ik zie dat ik nog geen vragen mag sluiten... ik mag alleen vragen sluiten als er een probleem mee is. Je kunt zelf een antwoord markeren... – Danny '365CSI' Engelman Jan 14 '16 at 13:59
1

I've answered a question similar to this before. You can achieve this by doing some changes in a copy of the display template that you are using to modify the date and time output to anything you like.

I'm not going to write it down again but i cover all the steps that you need to do here. The only difference is that i'm working with a different Display Template.

How-to-modify-time-format-property-mapping

This site is a big help when creating a custom date output.

Standard Date and Time Format Strings

1

In a ListView you can use the TEXT function in a Calculated Column;

see http://viewmaster365.com/365coach/#/Calculated_Column_Functions_List

TEXT ([DateTimeField],'dd-mm-yy hh:mm')

In a DisplayForm or Search results it is a minor javascript change to the DisplayTemplate

SharePoint adds a String.format
you can use/mix all these markers to format a Date value

String.format("{0:i}",new Date());  outputs: Wed Oct 07 2015 20:39:54 GMT+0200 (W. Europe Daylight Time)
String.format("{0:F}",new Date());  outputs: Wednesday, 07 October 2015 20:39:54
String.format("{0:f}",new Date());  outputs: Wednesday, 07 October 2015 20:39
String.format("{0:D}",new Date());  outputs: Wednesday, 07 October 2015
String.format("{0:s}",new Date());  outputs: 2015-10-07T20:39:54
String.format("{0:d}",new Date());  outputs: 10/07/2015
String.format("{0:dd}",new Date());  outputs: 07
String.format("{0:ddd}",new Date());  outputs: Wed
String.format("{0:dddd}",new Date());  outputs: Wednesday
String.format("{0:m}",new Date());  outputs: October 07
String.format("{0:M}",new Date());  outputs: October 07
String.format("{0:MM}",new Date());  outputs: 10
String.format("{0:MMM}",new Date());  outputs: Oct
String.format("{0:MMMM}",new Date());  outputs: October
String.format("{0:Y}",new Date());  outputs: 2015 October
String.format("{0:y}",new Date());  outputs: 2015 October
String.format("{0:yy}",new Date());  outputs: 15
String.format("{0:yyyy}",new Date());  outputs: 2015
String.format("{0:gg}",new Date());  outputs: A.D.
String.format("{0:T}",new Date());  outputs: 20:39:54
String.format("{0:t}",new Date());  outputs: 20:39
String.format("{0:HH}",new Date());  outputs: 20
String.format("{0:mm}",new Date());  outputs: 39
String.format("{0:ss}",new Date());  outputs: 54
String.format("{0:tt}",new Date());  outputs: AM or PM

J1 J5

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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