SPD: How to change 24hr format to 12hr format AM/PM

By | September 4, 2009

English

I’ve found this question in forum – but since it was not easy to explain by sentences, I would like to create a sample working option here.

For example you have this list as data source:

9-4-2009 7-30-07 AM

In the data source you have 24hr format (I use string type for my sample, but you can use normal DateTime).

In SharePoint, to display the 24hr format in 12hr format, you need to use DataFormWebpart + proper ddwrt function like this:

9-4-2009 7-58-28 AM

The ddwrt function you need to play is:

ddwrt:FormatDate(string([Field]),1033,5)

[Field] is the field where you have the data, in this case internal name of “24hr format”.
1033 is the culture
5 is the predefined format , you can use ‘M/d/yyyy hh:mm:ss tt’ instead.

 

And the final result will be,

9-4-2009 8-02-18 AM

 

Happy design!

Leave a Reply