SharePoint rest api VS 取出来时间不一致问题
2014-10-29 17:16
423 查看
在sharepoint里面发表了blog或者wiki! 在vs里面用wss对象模型或者 TEST API 取出来的时间有时遇到不一致的情况!
1.电脑系统设置时间和sharepoint里面的时间时区设置不一致:
Sharepoint中设置时区:
1. Site Settings.
2. Site Administration->Regional settings.
3. Time Zone
“UTC Casablanca”
2.在vs中取时间的代码问题!
SPListItem folder = splist.Folders[0];
LastModified = (folder["Last Updated"]).ToString()。
在样写就有误:LastModified = folder.Fields["Last Updated"].GetFieldValueAsHtml(folder["Last Updated"])。
我就是这样解决的!
3. 还有可能就是:
当使用SPListItem返回的时间是按照UTC时间(比北京时间晚8个小时),需要我们用代码去转换一下时间,示例如下:
//Create DateTime object, 如果是字符串的话,您可以使用DateTime.ParseExact去创建
DateTime time = DateTime.ParseExact(....);
// First get the current SPTimeZone of SPWeb:
SPTimeZone timeZone = web.RegionalSettings.TimeZone;
// Convert date and time in local:
DateTime localDT = timeZone.UTCToLocalTime (time);
4. 当然还有一种最好的办法就是:
DateTime dt = DateTime.Parse("youTime").ToLocalTime();
能解决问题的方法是最好的!
在sharepoint里面发表了blog或者wiki! 在vs里面用wss对象模型或者 TEST API 取出来的时间有时遇到不一致的情况!
1.电脑系统设置时间和sharepoint里面的时间时区设置不一致:
Sharepoint中设置时区:
1. Site Settings.
2. Site Administration->Regional settings.
3. Time Zone
“UTC Casablanca”
2.在vs中取时间的代码问题!
SPListItem folder = splist.Folders[0];
LastModified = (folder["Last Updated"]).ToString()。
在样写就有误:LastModified = folder.Fields["Last Updated"].GetFieldValueAsHtml(folder["Last Updated"])。
我就是这样解决的!
3. 还有可能就是:
当使用SPListItem返回的时间是按照UTC时间(比北京时间晚8个小时),需要我们用代码去转换一下时间,示例如下:
//Create DateTime object, 如果是字符串的话,您可以使用DateTime.ParseExact去创建
DateTime time = DateTime.ParseExact(....);
// First get the current SPTimeZone of SPWeb:
SPTimeZone timeZone = web.RegionalSettings.TimeZone;
// Convert date and time in local:
DateTime localDT = timeZone.UTCToLocalTime (time);
4. 当然还有一种最好的办法就是:
DateTime dt = DateTime.Parse("youTime").ToLocalTime();
能解决问题的方法是最好的!
相关文章推荐
- Windows 商店应用中使用 SharePoint REST API
- 使用Rest API开发SharePoint Online
- SharePoint REST API - 使用REST接口对列表设置自定义权限
- Post/Reply a post by Social feed REST API in SharePoint 2013
- SharePoint REST API - OData查询操作
- SharePoint REST API - 使用REST API和jQuery上传一个文件
- Rest Api how to retrieve list items from SharePoint Online
- SharePoint REST API - 文件夹和文件
- SharePoint REST API - 概述
- linq and rest api in sharepoint
- Net 访问 SharePoint Rest 报错问题
- SharePoint REST API - 基本操作(一)
- SharePoint REST API - 基本操作(二)
- SharePoint REST API - 一个请求批量操作
- SharePoint REST API - 同步SharePoint列表项
- SharePoint REST API - REST请求导航的数据结构
- SharePoint REST API - 使用REST接口对列表设置自定义权限
- 关于mysql数据库时间 和查询出来的时间不一致问题
- SharePoint API如何处理时区问题
- SharePoint REST api