question

KarteekKoraganji-2950 avatar image
0 Votes"
KarteekKoraganji-2950 asked MichaelHan-MSFT answered

Is it possible to get current date time of SharePoint Team Site hosted server through Sharepoint REST API?

HI,

After Googling I came to know that, SP Rest api provides end point to retrieve Time Zone settings.
<site url>+ _api/web/RegionalSettings/TimeZone
92089-timezone.png

offset = (data.d.Information.Bias + data.d.Information.DaylightBias) / 60.0
new Date( new Date().getTime() - offset x 3600 x 1000)

but the time I am getting not exactly matching.
Please suggest.


office-sharepoint-online
timezone.png (65.1 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

MichaelHan-MSFT avatar image
0 Votes"
MichaelHan-MSFT answered

Hi @KarteekKoraganji-2950,

The way you used is correct.

By default, JavaScript will use the browser's time zone. Just convert to UTC time:

 new Date( new Date().getTime() - offset  * 3600 * 1000).toUTCString()


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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.