I'm working in SharePoint 2013 using REST API to retrieve Date field values.
(我正在使用REST API在SharePoint 2013中工作,以检索“日期”字段值。)
I need to get the from now value of those fields and so I am using JS Moment, but so far I can't the moment code to work at all.(我需要获取这些字段的从现在开始的值,因此我正在使用JS Moment,但到目前为止,我暂时无法正常工作。)
Here's some snippets of my SharePoint REST API code:(这是我的SharePoint REST API代码的一些片段:)
url:/sites/regulatory3/testdashboard/_api/web/lists/GetByTitle('Contacts')/items?"$Select=Created,OData__x0031_st_x0020_Draft_x0020_Test",
$.each(data.d.results, function (key, value) {
var createdDate1 = $.format.date(value.Created, 'dd/MM/yyyy');
var createdDate2 = createdDate1.toString();
var createdDate3 = new Date(createdDate2);
var firstDueDate1 = $.format.date(value.OData__x0031_st_x0020_Draft_x0020_Test, 'd MMM yyyy');
var firstDueDate2 = firstDueDate1.toString();
var firstDueDate3 = new Date(firstDueDate2);
Here's what I have tried:
(这是我尝试过的:)
var createdDate4 = moment(createdDate3).toNow();
var firstDueDate4 = moment(firstDueDate3).toNow();
test1 = moment([2019, 1, 29]).fromNow(); //example from tutorials - Not relevant to what I'm doing
test2 = moment().subtract(5, 'h'); //example from tutorials - Not relevant to what I'm doing
Finally, here's my include for Moment:
(最后,这是我对Moment的包含:)
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-dateFormat/1.0/jquery.dateFormat.min.js" type="text/javascript"></script>
Has anyone else seen this problem?
(还有其他人看到过这个问题吗?)
If so please provide guidance and code examples.(如果是这样,请提供指导和代码示例。)
ask by Tom Molskow translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…