0

I am fetching records from the list using rest api by filtering date field in it. however i am getting a different result from different time zone. any kind of help will be appreciable.

var today =moment.utc(new Date()).toISOString();//new Date().toISOString(); 
 $.ajax({
            url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('" + companyNews + "')/items?$select=Id,Title,Created,Published_x0020_Date&$filter=((Published_x0020_Date le datetime'" + today + "' or Published_x0020_Date eq null) and (EndDate ge datetime'" + today + "' or EndDate eq null))&$orderby=Published_x0020_Date desc",
            headers: {
                "Accept": "application/json;odata=verbose",
                "Content-Type": "application/json;odata=verbose",
            },
            success: function(data) {
                if (data.d.results) {
}
  • Check the datetime value in "Published Date" column in the list in different time zones. If it is different then your REST API result is okay. – Ahmad Zia Aug 23 '17 at 23:27
  • @Ramseh, did you find the solution to this issue? – Virendra Kumar Apr 2 at 9:01
  • @VirendraKumar My site was running in 3 time zone so I have placed the condition for that 3 time zone and plus-minus the hours to datetime that passed to api. – Ramesh Apr 3 at 9:37

Your Answer

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

Browse other questions tagged or ask your own question.