SharePoint Time Zone confusion

Working in an environment that hosts servers offering SharePoint at a world wide level I see a common confusion in how SharePoint deals with time zones in relation to files.

Lets step through some examples, and then we can address it with a solution that is appropriate for your circumstance.

 

The Basics
(You can skip this section if you are just looking for the fix)

First thing to understand is how the SharePoint server stores your files. When you upload a file regardless of what time zone you are in SharePoint server stores it into the SQL database using the Co-ordinated Universal Time (UTC) time zone.

NOTE: Never change set server time or time zones of any server in your SharePoint farm.

I created an example file on the server desktop with the following date/time properties.

image

My server time zone is set to UTC. I then uploaded the file to SharePoint document library. When I uploaded the document 11 minutes later it reset the ‘created’ and ‘modified’ values. This happens regardless of the file type.

image

Using a handy tool called SharePoint Manager I was able to track the documents unique ID and file properties.

(This is a very useful tool which should be in your arsenal of SharePoint troubleshooting tools.)

image

image

I do not recommend directly viewing, or modifying, any of your SharePoint SQL databases.

Keep in mind SharePoint Manager uses the SharePoint API to pull all meta data. SharePoint Meta data is filtered, and set to SharePoint server settings. In the raw SQL content database we can verify that the file is stored in UTC time zone regardless of what ever time zones any server via this Microsoft article 2.2.7.3 AllUserData Table.

The implication here is that regardless of which time zone the file is uploaded the time zone data is reset and stored in UTC.

SharePoint Settings

There are three different places you can change time zone settings depending on your need. I’ll start from the highest SharePoint server setting to the client setting.

Web App Level

The first is top level web application level set from the SharePoint Central Admin. The default as we can see there is that no time zone it set.

image

When the setting is blank the time zone is set to what ever the time zone of the server is set. When applying the time zone setting at the web application level this applies this will make a default setting to all site collections that are within this web application. Generally I would only recommend setting this if you are confident that all of your SharePoint users will be in the same time zone. Remember that this only the default, and can be changed at the site collection or user level.

Site Collection Level

The second level working downward is to set the default time zone at the individual site collection. This is a more common time zone setting to set for your SharePoint site. You will want to set the time zone where majority of your users will be physically located.

Site Actions>Site Settings>Site Administration>Regional Settings

image

There will be several other settings that can be set at this level for the SharePoint site collection and SharePoint users. You will need to be at least a site collection administrator to make this change. As before these default level can be over-ridden at lower user level.

User Level

The last and lowest level will be at the SharePoint user level. Looking at my SharePoint site from my workstation I can see the following.

image

While my workstation is set to the Central Time zone the SharePoint Client is still set to the default UTC time zone. It is important to note that if you open the same document library using the ‘Explorer View’ that the time are then translated to your workstation’s set time zone.

image

To set your SharePoint user level time zone

Screenshot - 5_22_2012 , 11_00_12 AM

Your Name on the upper right hand side>My Settings> My Regional Settings

From there you can set user time zone settings for the user level. This will then correct the time zone discrepancy.

-Javi

About the Author

2 thoughts on “SharePoint Time Zone confusion

    • Author gravatar

      SharePoint does not automatically store dates in UTC. Dates are stored in the timezone configured on the OS level of the WFE you’re hitting. Just try to save 1900-01-01T00:00:00Z (earliest possible date in SP) in a DateTime field on a server which is on US Eastern time. It won’t work. So the reason its UTC in your example is because your server happens to be on Unversal Time.

      • Author gravatar

        Internally (in the database), dates ARE stored in UTC.

        However, every time you access them they are converted to the current context offset; this applies both through the UI and through the API (i.e. programmatically).

        Although the API takes a DateTime value, it ignores the setting of DateTimeKind. i.e. trying to putting 00:00 and setting to Utc doesn’t actually work; it is still interpreted as a local time.

        You are correct that the article, which uses SharePoint Manager (which uses the API), won’t get a UTC time unless the region (or default) is set to UTC.

        The only way to see the internal UTC values is to open up the actual database with SQL Manager and look directly.

        Usually this is irrelevant, as every access (API or UI) converts to the region of the current context.

        The only time there is a problem is if you are writing server side code that retrieves values from the API with elevated permissions; in this case the code runs in the elevated context, which is usually the site collection default regional settings.

        If the user has custom settings the you need to adjust when translating back from the elevated context to the user context.

Leave a Reply

%d bloggers like this: