How to format date in SharePoint XSL templates?

In many projects when using CQWP web parts you need to customize date format. By default, SharePoint gives date with time, but we often need only date. Here is a simple scenario:

  1. First you need to reference the ddwrt namespace at the top of your <xsl:stylesheet> tag:
    xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime
  2. In order to display custom date format you have to use the following code (replace @ArticleStartDate with your column ):
    xsl:value-of select="ddwrt:FormatDate(@ArticleStartDate, 2057, 1)"
  3. Save. Publish. Check results 😉

 

Properties of Javascript context object (.ctx) on SharePoint 2013

1: Rank:11.27 
2: DocId:5367 
3: WorkId:5367 
4: Title:test123 
5: Author:Developer 
6: Size:0 
7: Path:http://example.com/test/DispForm.aspx?ID=1 
8: Description: 
9: Write:Mon Jun 3 19:55:58 UTC+0300 2013 
10: CollapsingStatus:0 
11: HitHighlightedSummary: 
12: HitHighlightedProperties:<HHTitle><c0>test123</c0></HHTitle><HHUrl>
13: http://example.com/test/DispForm.aspx?ID=1</HHUrl><author hashh="0">Developer</author> 
14: contentclass:STS_ListItem_GenericList 
15: PictureThumbnailURL: 
16: ServerRedirectedURL: 
17: ServerRedirectedEmbedURL: 
18: ServerRedirectedPreviewURL: 
19: FileExtension:aspx 
20: ContentTypeId:0x0100...
21: ParentLink:http://example.com/test/AllItems.aspx 
22: ViewsLifeTime: 
23: ViewsRecent: 
24: SectionNames: 
25: SectionIndexes: 
26: SiteLogo: 
27: SiteDescription: 
28: deeplinks: 
29: importance: 
30: SiteName:http://example.com
31: IsDocument:No 
32: LastModifiedTime:Monday, June 3, 2013 
33: FileType: 
34: IsContainer:No 
35: WebTemplate: 
36: SecondaryFileExtension: 
37: docaclmeta: 
38: OriginalPath:http://example.com/test/DispForm.aspx?ID=1 
39: EditorOWSUSER:Developer 
40: DisplayAuthor:Developer 
41: ResultTypeIdList:38;6 
42: PartitionId:0c37852b-34d0-418e-91c6-2ac25af4be5b 
43: UrlZone:0 
44: AAMEnabledManagedProperties:AttachmentURI;deeplinks;DefaultEncodingURL;ExternalMediaURL;HierarchyUrl;
45: OrgParentUrls;OrgUrls;OriginalPath;ParentLink;Path;PictureThumbnailURL;PictureURL;PublishingImage;
46: recommendedfor;ServerRedirectedEmbedURL;ServerRedirectedPreviewURL;ServerRedirectedURL;SiteLogo;
47: SitePath;SPSiteURL;UserEncodingURL 
48: ResultTypeId:38 
49: RenderTemplateId:~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_test.js 
50: piSearchResultId:0_1 
51: ParentTableReference:[object Object] 
52: csr_id:ctl00_PlaceHolderMain_ctl01_csr2_item