Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SharePoint 2013 REST Date Time Field Issue

I have a SharePoint 2013 List containing DateTime column field. I read that list items using REST Web-service from Java. In the REST call it gives a Date off by 1 day from the date shows in the list.

For example: List date shows as 7/12/2014 in table. REST XML response result gives "2014-07-11T16:00:00Z".

How to Fix this issue?

like image 953
Devshan Avatar asked Oct 31 '22 19:10

Devshan


1 Answers

This happens, because in SharePoint UI, when you're setting the date field without time, it will assume that you're setting dd-MM-yyyy 00:00:00 of your local time. But in database it will try to adjust the date to Universal Time. And that's what you're getting from REST service.

If you're LocaleId is the same in the browser as it was on the server during saving the date, then simple javascript new Date("2014-07-11T16:00:00Z") should return right value. If not, then you will have to manually adjust the timezone. Regional settings may be something that can help you. In SP 2013 you can also access it from the REST Api:

http://msdn.microsoft.com/en-us/library/office/jj246227(v=office.15).aspx

like image 165
Marek Kembrowski Avatar answered Nov 09 '22 16:11

Marek Kembrowski