0

I am having issues with dates in a SharePoint 2013 list.

At a high level I am archiving the dates of the selected item in List1, storing them in List 2. The dates in the selected item are updated to new dates with my code.

Seems when I retrieve the dates from List1 using a REST call I get the proper date back. I am converting the date to a MM/DD/YYYY format and then storing it in List2 but the List2 date is off by one.

The argument ISODate is the value from the REST response so the value I am getting from REST looks like "2020-02-17T06:00:00Z". List1 date is 2/17/2020. So all good.

The return (mydate) is 2/16/2020 and this value is getting stored into List2 and also displayed on my custom form...but it's wrong!

I could add one day to the date but that is likely not the solution here. Not sure why that return date is getting reduced by one day and how to resolve it.

GetDate: function (isoDate) //3.5 namespace addition
    {
        
        var testdate=new Date(isoDate);
        var mydate=moment(testdate).format('MM/DD/YYYY');
        
        return mydate;

I have looked at other posts but they have not been useful.

1
0

This is Known behavior of SharePoint REST APIs.

It's a common issue when retrieving the date object in SharePoint because REST do not bring back the client side time, it brings back the server time.

You can find more explanation in below articles:

  1. SharePoint time, is not your time, is not their time
  2. Rest returns wrong date in sharepoint 2013

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.