April 1, 2021

Explained: Behavior of Date and Time column value in SharePoint List/Library

Introduction:

We implemented Intranet Portal on SharePoint Online for a Real Estate Agency based out of Washington, United States. We had to tackle several questions regarding Date and Time in SharePoint from different business users after go-live. We conducted training sessions with the business users and explained the behavior of Date and Time in SharePoint. In this article, we will see how SharePoint shows the value of the Date and Time column in lists/libraries.

Many times, we observe, value of the Date and Time column is different for different users and when we try to get the value of the same Date and Time column using Rest API, it will return a different value.

So, in this blog, we will understand why the value of the Date and Time column is different at different places.


Which settings SharePoint considers to show the value of the Date and Time column?

The date-time value that SharePoint shows does not depend on the time zone of the user's computer.

SharePoint considers the below time zones to show the value of the Date and Time column:

  1. Time zone selected by currently logged-in user in their profile.
  2. Time zone selected in Regional settings of the site settings.

How SharePoint shows the value of Date Time column?

Now we will understand how SharePoint shows the value of the date time column.

  • If the user has selected a time zone in his/her profile, then SharePoint will display date time in that particular time zone.
  • If the user has not selected a time zone in his/her profile, then SharePoint will display date time in the time zone which is selected in regional settings of the specific SharePoint site.


Let's understand this with an example:

Here, we have created one list and added a Date and Time column to the list. In site settings of this site collection, we have selected (UTC-08:00) Pacific Time (US and Canada) time zone.

We will check with two different users, which has different regional settings in their user profile.

  • User 1: This user has selected (UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi time zone in his user profile.
  • User 2: This user has not selected any time zone in his user profile.

Now, we are creating one item in the list as "User 1" and add below values:


  • Now for "User 1", it will display the date-time value which was selected while creating the item. So, for User 1 it will display as below:


  • As the item created by "User 1" and time zone selected by User 1 is (UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi, SharePoint will display date time in selected (UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi time zone.
  • But for "User 2", it will display a different date time because "User 2" has not selected time zone in his user profile. So, it will display date time in the time zone selected in the regional settings of the site collection. It means it will display date time in (UTC-08:00) Pacific Time (US and Canada) time zone.


How SharePoint returns the value of Date and Time column in REST API?

  • If we try to get the Date and Time column value of the above item using REST API, it will return a different value.
  • Here we have hit the REST API in the browser it returns the value as shown below screenshot:

REST API: /_api/web/lists/getbytitle('Sample')/items?$select=Title,Sample_x0020_Date_x0020_Field

  • So the value returned is not in the time zone of site collection or time zone of the current user's user profile's time zone.
  • It is in UTC time because SharePoint stores all the DateTime values in UTC time (REST API returns Date and Time column value in UTC).

Conclusion:

This is how SharePoint shows the value of the Date and Time column. Hope this blog will be helpful for you!

If you have any questions you can reach out to our SharePoint Consulting team here.

No comments:

Post a Comment