How to avoid Daylight saving time while showing for different timezone users in SPFx?

Chintan Upadhayay 1 Reputation point
2020-10-21T15:27:45.583+00:00

We are facing with issue on saving date time field for DST(Daylight saving time) in SharePoint list

We are using moment js [moment.utc("2020-12-21T02:00:00Z").utcOffset("+1").format("M/D/YYYY LT")] for change SharePoint returned date to User regional timezone offset to show user timezone based date.

It shows correct time for Oct month [UTC+02:00,CET] but is show 1 hour behind for Dec [UTC+01:00,CET].

If we perform below action with Non PST user, in my case [(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna]

We have checked in the SharePoint Calendar List, if we create a item from SP list, it save exact time what I pass to Start/End column
but if we do with REST API after converting input date To PST [Since I am saving Non PST user date to PST] , then localTimeToUTC [Via RegionalSettings localTimeToUTC API], and then passing returned output date to save API. But it shows different time if compare with added entry from SharePoint.

I attaching screenshots for more details.

PST User View
34028-pstview.png

Non PST User View
34111-utc1.png

Response From Non PST User for event "REST API Dec 21, 10AM-11AM, UTC+01:00"

34077-responsefromnonpstuser.png

So what we are trying to identify

  1. How SharePoint save the dates when we create items from SharePoint List?
  2. How can achieve the same dates as SharePoint do using REST API while saving or display the events?
Microsoft 365 and Office SharePoint For business Windows
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. ZhengyuGuo 10,586 Reputation points Moderator
    2020-10-22T06:45:53.667+00:00

    Hi @Chintan Upadhayay ,

    1. SharePoint save date time value in UTC DateTime which without any time zone (UTC+0).
    2. Using Rest API set "EventDate" and "EndDate" column, just need to pass UTC datetime value, then SharePoint UI will display real time based on Time Zone settings automatically:

    34234-snipaste-2020-10-22-14-45-25.png

    In Rest API return the date(UTC+0)

    34215-snipaste-2020-10-22-14-41-56.png

    In calendar UI (UTC+1):

    34128-snipaste-2020-10-22-14-42-38.png


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.