Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在xml响应中显示带时区偏移量的DateTime_C#_Asp.net_.net_Web Services - Fatal编程技术网

C# 在xml响应中显示带时区偏移量的DateTime

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>

我有一个.amsx Web服务,它有以下方法 [网络方法]

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)将其设置为本地感谢您,指定了解决问题的种类属性。添加作为答案,请接受:)