I am working on a solution (on SharePoint Online) which is used by users in different timezones. SharePoint site is configured for "W. Europe Standard Time".
Following occurs:
- A user from US creates a list item using SharePoint standard form and fill in a date only field with September 15.
- When the user opens the item and views the properties it shows September 15.
- There is custom view build that retrieves the list item data using JSOM. Item is retrieved with "getItemById" and values are read with "get_fieldValues".
- I, as a user from Europe, see in both the custom solution and in SharePoint UI September 15.
- User that created the items sees two different values. September 15 in SharePoint UI and September 14 in the custom solution (which retrieves the info via JSOM)
I have looked at how the data is returned when get_fieldValues is used and it look like this for a US user: Sun Aug 14 2016 17:00:00 GMT-0500 (Central Daylight Time). I inspected the response body of the call and can see that it return a UTC time which is then translated to this local time in the process of reading the value. Raw response for a date fields looks like this: Date(1469656800000).
Also tested to see how REST API returns values and there I see that date values are turned in UTC like "2016-08-14T22:00:00Z". One possible solution for my problem is to switch to REST api and show the dates in web region, this is what SharePoint appears to be doing in his own UI.
But I don't want to re-build the data retrieval process and am looking for a way to use JSOM and somehow workaround/solve this issue. Any ideas how to do this?