Inside PnP Modern Search Web Part, how i can show the Date Time in the sharepoint site local time zone

john john Pter 300 Reputation points
2024-08-21T21:51:14.66+00:00

I am working on a SharePoint online site collection which have this regional settings:-

image

And i have a SharePoint column of type Date/Time, now inside SharePoint list view the date/time will be show as follow:-

image

which respect the site regional settings. now for the above site column >> i have a managed property and when i am showing this manage property inside the PnP Modern Search Result web part i will get the value based on UTC, as follow: -

image

so how i can show the date/time inside my Search Result to be equal to what is shown inside the list view?

Here is how i am rendering the column value inside the Search Result web part settings (resource.fields.RefinableDate01):-

image

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,926 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Xyza Xue_MSFT 23,931 Reputation points Microsoft Vendor
    2024-08-22T07:31:06.8966667+00:00

    Hi @john john Pter ,

    When we fetch the values of any DateTime fields within a SharePoint list or library, the values are returned in UTC format, as they are stored in UTC format internally. Within an webpart it just displays the UTC time.

    Unfortunately, this behavior is by design and it cannot be changed.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    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.