locked
sharepoint 2010 json api return one day before date. RRS feed

  • Question

  • Dear All,

    I trying following code getting list items from sharepoint using json.

    In list date is from date is "08/24/2016" but it returns one date before i.e. "08/23/2016".

    Can anyone please tell me how to get exact date ? Do I need to do ant setting for the site ?

    Get Item Code:

    query = "/_vti_bin/listdata.svc/MasterList?$select=Id,FromDate,ToDate"
    var getItems = function (query) {
                    var deferred = $q.defer();
                    $.ajax({
                        url: http://ABC/sites/WOW + query,
                        method: "GET",
                        headers: {
                            "Accept": "application/json;odata=verbose",
                        }
                    })
                          .then(function success(result) {                           deferred.resolve(result);
                          }
                           , function error(result, status) {
                               deferred.reject(status);
                           });
                    return deferred.promise;
                };

    Date Conversion Code:

    function parseJsonDate(jsonDateString) {
                    if (jsonDateString !== undefined && jsonDateString !== null)
                      return new Date(parseInt(jsonDateString.replace('/Date(', '')));
                    else
                        return "";
                };

    Thanks,

    Harish Patil

    Wednesday, August 24, 2016 5:43 AM

Answers

All replies