1

SharePoint 2010

I'm using a standard Calendar. There are two fields from the default Event content type called Start Time and End Time. Once an Event has been created on the calendar, and I view the event from the default DispForm.aspx page, the format of the date/time looks like the following: enter image description here

I would like to change the display format of both these fields to just the hour and minute AM/PM(Would like something like this in .Net "hh:mm tt"). I've tried playing with some JavaScript with the help of jQuery and didn't really get anywhere.

var oldFormat = new Date($("selector").text()); // Turns the text into a Date object

After playing with the methods on the this Date object, I found I could use somethnig like this. I thought this was a bit messy and was curious if there was an easier way.

  • Can you check the regional setting under site setting as I think you should be able to achieve this without JScript? – SharePointer May 11 '17 at 18:57
2

Try to edit your display form via SharePoint designer

Replace your date field (it should look like <xsl:value-of select="@Startdate/>) to

<xsl:value-of select="ddwrt:FormatDateTime(string(@Startdate) ,1033 ,'M/dd/yyyy h:mm tt')"/>

or

<xsl:value-of select="ddwrt:FormatDateTime(string(@Startdate) ,1033 ,1)"/>

For more details check

  • This is exactly what I was looking for. I actually previously used your second suggestion which didn't work. Thank you! – HiTech May 11 '17 at 19:38

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.