A quick tips to formatting DateTime in XSLT for Content Qury Webpart through Editing Sharepoint ItemStyle or manually configure Dataview Webpart.
To achieve the desire format, there are string variable needed. (LCID & FormatFlag)
LCID code is the localize language used by the hosting machine. Full listing of LCID code could be found Here. For illustration purpose, English-United State (1033) is used in following example.
FormatFlag is the format apply to the date and time itself. FormatFlag can be apply using number or string format. A sample of numbering FormatFlag of en-US is available in the image below(Source). Full listing of FormatFlag for each language Here.
As for the text format a full list of FormatFlag can be found Here.
Example:
Numbering FormatFlag |
ddwrt:FormatDate(string(@EventDate), 1033, 5) |
= 5/9/2007 12:00 AM |
String FormatFlag |
ddwrt:FormatDate(string(@EventDate), 1033, d/m/yyyy) |
=5/9/2007 |
ddwrt:FormatDate(string(@EventDate), 1033, dd/m/yyyy) |
=05/9/2007 |
ddwrt:FormatDate(string(@EventDate), 1033, dd/mmm/yyyy) |
=05/Sep/2007 |
Other useful resources:
- SharePoint Data View Web Part Extension Functions in the ddwrt Namespace
- Share The Learning: The LCID and FormatFlag in the ddwrt:FormatDate method:
- Kirk Evans Blog : Showing a List of Today’s Birthdays in SharePoint (Format TodayIso format)
- Share The Learning: Revisiting ddwrt and FormatDate (Generate LCID list)
No comments:
Post a Comment