简体   繁体   English

如何使用CSOM模型获取SharePoint服务器日期时间?

[英]How can I get SharePoint server datetime using CSOM model?

I'm creating a service that will notify people about new tasks in SharePoint. 我正在创建一个服务,通知人们有关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. 为此,我必须以某种方式得到它的服务器日期时间,因为在将它与datetime.now结果进行比较时,时间值存在巨大的不同步差距。

SharePoint store datetime as UTC time, so try to use TimeZone.UTCToLocalTime SharePoint存储日期时间为UTC时间,因此请尝试使用TimeZone.UTCToLocalTime

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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