简体   繁体   中英

How can I get SharePoint server datetime using CSOM model?

I'm creating a service that will notify people about new tasks in SharePoint. For this I have to somehow get it's server datetime due to a huge desynchronisation gaps in time value when comparing it to datetime.now result.

SharePoint store datetime as UTC time, so try to use TimeZone.UTCToLocalTime

var localTime = context.Web.RegionalSettings.TimeZone.UTCToLocalTime((DateTime)listItem.FieldValues["Created"]);
                context.ExecuteQuery();
                Console.WriteLine(localTime.Value);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM