我在 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