码迷,mamicode.com
首页 > 其他好文 > 详细

How to get current date time in SharePoint Site Time Zone

时间:2015-01-30 15:48:36      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:

if SharePoint time zone is different from server:

SPWeb currentWeb = SPContext.Current.Web;
DateTime utcDateTime = DateTime.UtcNow;
DateTime locateDate = currentWeb.RegionalSettings.TimeZone.UTCToLocalTime(utcDateTime);


by the way:if query the data with the datetime field, you need consider the time zone using StorageTZ=‘true‘ , then the caml will query the data convert date time  to the server time

<Geq><FieldRef Name='SetDate'/><Value Type='DateTime' StorageTZ='true' IncludeTimeValue='FALSE'><Today/></Value></Geq>


How to get current date time in SharePoint Site Time Zone

标签:

原文地址:http://blog.csdn.net/tristan_dong/article/details/43307479

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!