2
我想从CRM中检索我的数据。但是,在做这件事时,它看起来像是在将文化应用到日期时间领域。如何防止日期时间使用文化信息在XML中序列化?
我已将日期时间保存在CRM中 - 01/08/2017 12:00 AM。
但是,当我取回从FetchXML帮助这个数据,它给了我31/07/2017 06:30下午
我已培养我的Global.asax文件 -
protected void Application_BeginRequest()
{
CultureInfo info = new CultureInfo(System.Threading.Thread.CurrentThread.CurrentCulture.ToString());
info.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";
System.Threading.Thread.CurrentThread.CurrentCulture = info;
}
和web.config文件 -
<globalization culture="en-GB" />
现在,当我检索CRM数据 -
foreach (var item in result2.Entities)
{
model.SightTestDate = Convert.ToDateTime(item["oph_claimreceiveddate"]);
}
它给了我这个日期 - 31/07/2017 06:30 PM
我在这里错过了什么?
看起来你是问题不是关于文化,但关于时区 – Rik