DateTime Inconsistency Issues in O365 REST API

All date/time stamps appear to be returned with the local time zone offset relevant to the customer's region in O365 - except for one case.  In a calendar event,  if the 'All Day Event' toggle is set to true - then the REST API query will return the event Start Date (EventDate) and End Date as UTC.  If the toggle is set to false, then it will return those dates with the local time zone offset (see images below). 

Why the difference?  Suddenly my JS code stops working correctly when users begin checking the 'All Day Event' setting, took me many hours to figure out why.  Let's pick one, and stick to it. 




  • Edited by Tracy'S 11 hours 57 minutes ago
August 22nd, 2015 1:03am

Hi,

As a workaround, check whether the "fAllDayEvent" value is false, then use the following URI to convert the data to local time.

http://<sitecollection>/<site>/_api/web/RegionalSettings/TimeZones(timzoneid)/utcToLocalTime(date)

Example:

https://xxx.sharepoint.com/sites/dennis/_api/web/RegionalSettings/timeZone/utcToLocalTime('2015-08-17T06:00:00Z')

More information:

http://www.malindesilva.net/2015/08/sharepoint-datetime-field-rest-api-time.html

https://msdn.microsoft.com/EN-US/library/office/jj245318.aspx

Best Regards,

Dennis Guo

Free Windows Admin Tool Kit Click here and download it now
August 24th, 2015 7:19am

Hi Dennis,

I appreciate the response and the suggested workaround.  I'm more concerned about the general inconsistency, and the time lost in troubleshooting why that one case was not working correctly and all my other JS code relating to date/time columns worked fine. 

Warmly,

-Tracy

August 26th, 2015 3:47pm

Hi,

If the 'All Day Event' toggle is set to true, the hour and minute of the Start Time is the start time of the day, the hour and minute of the End Time is the end time of the day. The hour and minutes of Start Time and End Time  are generated by system. I check the Data store in the Database as the screenshot below:

Best Regards,

Dennis Guo

Free Windows Admin Tool Kit Click here and download it now
August 26th, 2015 10:24pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics