【发布时间】:2019-08-14 01:10:57
【问题描述】:
我正在使用 SharePoint 2013,并且为内容搜索 Web 部件创建了一个自定义显示模板。我的三个字段使用日期,并且所有三个都以长格式返回日期。我想以短格式返回日期,但似乎无法正常工作。
我已经尝试了这些博客文章中的建议:
https://sharedpointtips.blogspot.com/2015/01/sharepoint-2013-display-template.html
https://sharepoint.protiviti.com/blog/Lists/Posts/Post.aspx?ID=132
http://sharepointfordeveloper.blogspot.com/2015/11/shareppoint-2013-ctx-variable-and-its_17.html
在标题中:
'Review Date'{Review Date Label}:'ReviewDateOWSDATE',
在 JavaScript 部分我试过这个:
var shortDate = Srch.U.toFormattedDate(dateresponsedue,'ShortDatePattern');
还有这个:
var shortDate2 = Srch.U.toFormattedDate(shortDate, 'ShortDatePattern');```
And this:
```var shortDate = Srch.U.toFormattedDate(ctx.CurrentItem.DateResponseDueforReviewOWSDATE, 'ShortDatePattern');```
This is my display code:
```<td rowspan="3" width="85px" style="text-align:center;"> _#= shortDate =#_ </td>'''
I need the date display to change from something like this:
2019-07-11T05:00:00Z;7/11/2019 5:00:00 AM
To something like this:
2019-07-11
【问题讨论】:
标签: javascript sharepoint-2013 display-templates