khurram
khurram

Reputation: 1070

Show DateTime with timezone offset in xml response

I have a .amsx Web Service, which has following method [WebMethod]

public SalesList GetAgentSalesDetail()
{ .....
}

It returns me xml response like this.

<Sales>
<SaleInfo>
<SaleID>71076</SaleID>
<SaleDate>2014-03-03T18:22:54</SaleDate>
<PricePaid>9.99</PricePaid>
</SaleInfo>
</Sales>

My server's time zone is CST and I have DateTime Property of SaleDate. The question is how can I show the timestamp including time zone offset so instead of "2014-03-03T18:22:54" , I want to show "2014-03-03T18:22:54-05:00".

Upvotes: 1

Views: 232

Answers (1)

wal
wal

Reputation: 17749

what is the value of SaleInfo.SaleDate.Kind ?

try setting this to Local using

salesInfo.SaleDate = DateTime.SpecifyKind(salesInfo.SaleDate, DateTimeKind.Local);

Upvotes: 1

Related Questions