C# 在xml响应中显示带时区偏移量的DateTime
我有一个.amsx Web服务,它有以下方法 [网络方法]C# 在xml响应中显示带时区偏移量的DateTime,c#,asp.net,.net,web-services,C#,Asp.net,.net,Web Services,我有一个.amsx Web服务,它有以下方法 [网络方法] public SalesList GetAgentSalesDetail() { ..... } 它像这样返回xml响应 <Sales> <SaleInfo> <SaleID>71076</SaleID> <SaleDate>2014-03-03T18:22:54</SaleDate> <PricePaid>9.99</PricePaid>
public SalesList GetAgentSalesDetail()
{ .....
}
它像这样返回xml响应
<Sales>
<SaleInfo>
<SaleID>71076</SaleID>
<SaleDate>2014-03-03T18:22:54</SaleDate>
<PricePaid>9.99</PricePaid>
</SaleInfo>
</Sales>
71076
2014-03-03T18:22:54
9.99
我的服务器的时区是CST,我有SaleDate的DateTime属性。问题是如何显示包含时区偏移的时间戳,因此我想显示的不是“2014-03-03T18:22:54”
“2014-03-03T18:22:54-05:00”SaleInfo.SaleDate.Kind的值是多少 尝试使用将此设置为本地
salesInfo.SaleDate = DateTime.SpecifyKind(salesInfo.SaleDate, DateTimeKind.Local);
您的
SaleDate
房产的种类是什么?如果从db(未指定)中提取结果,则尝试将其更改为Local
,它是类中的DateTime变量,timestamp是db中的数据类型。SaleInfo.SaleDate.Kind
的值是多少?尝试使用salesInfo.SaleDate=DateTime.SpecifyKind(salesInfo.SaleDate,DateTimeKind.local)将其设置为本地代码>感谢您,指定了解决问题的种类属性。添加作为答案,请接受:)