【发布时间】:2020-06-20 01:42:59
【问题描述】:
我将 DateTime 值保存在 SharePoint 列表中的一个字段中:
//request is an entity that has all he fields in the list, I am only showing DueDate in the below code
if (txtdatepicker.Text != String.Empty)
{
DateTime dueDate;
if (DateTime.TryParse(txtdatepicker.Text, out dueDate))
{
request.DueDate = dueDate;//Output {9/30/2017 12:00:00 AM}
}
}
日期在 SharePoint 列表中正确保存为 截止日期:9/30/2017。
现在的问题是当我尝试检索此日期值时:
if (LI[Constants.FieldName_ReqLst_DueDate] != null)
req.DueDate = (DateTime)LI[Constants.FieldName_ReqLst_DueDate];//Output {9/29/2017 6:30:00 PM}
我在这里得到的输出与保存的值完全不同。如何从 SharPoint DateTime 列中获取正确的日期值?
我试过 DateTime.Parse(Convert.ToString(LI[Constants.FieldName_ReqLst_DueDate])).ToLocalTime() 在本地机器上可以正常工作,但如果部署在服务器上就不行了。
【问题讨论】:
标签: c# datetime sharepoint-2013 csom