Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

A list includes a column "Date" of type Date and Time, Date and Time Format is Date Only. An item is saved via web-service and is set to value such as 2013-04-01T00:00:00Z.

When this same item is saved via website (nothing needs to be changed), the column continues to read on website as "1/13/2013" but web-service now returns 2013-03-31T23:00:00Z.

In other words, we write to SharePoint 2013-04-01T00:00:00Z, do nothing with this value and then we get back 2013-03-31T23:00:00Z instead of original value.

This may be related to the fact that DST kicked in on Sunday, March 31.

Is there a way to prevent SharePoint form changing the date without resorting to storing date as string and such?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

There is no way (that I know of) to prevent SharePoint from converting dates between local and UTC times.

When you save the date via web service with the value of 2013-04-01T00:00:00Z it is saved directly as you specified (which is UTC). When you save that value via the website (I assume as a field in a list) then SharePoint will translate that value to UTC based on the time zone settings of the Web. (aka Site). In your case this appears to be UTC+1. Note that when you enter the time into a Date column, you are NOT specifying 2013-04-01T00:00:00Z, you are providing a simple date string, (for example, 4/2/2013 in the US) which is transated to UTC.

If data is both saved and retrieved from the list programmatically, then you can handle the difference however you'd like. However, if you are using the SharePoint user interface to either enter or retrieve the data then you should adjust your handling of the date in your programming to account for the change.

Here is a useful web page: http://www.stum.de/2010/06/10/dealing-with-multiple-time-zones-in-sharepoint-2010/

share|improve this answer
    
That looks like a good explanation. Web site's timezone however is "(UTC) GMT", would you expect this scenario to hold? –  zzandy Apr 2 '13 at 16:02
    
Yes, due to daylight savings as you mentioned. I confirmed the same behavior on a site of mine. To completely avoid this, I imagine you would need to select "(UTC) Coordinated Universal Time". Note that changing the time zone of a site will not update any data, so after changing the time zone you could see incorrect dates. –  Chloraphil Apr 2 '13 at 16:41
    
Yes, that's what we're observing as well. Changing to "UTC Universal Coordinated Time" fixes the problem, as well as changing field's format from Date Only to Date and Time. –  zzandy Apr 3 '13 at 7:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.