Reputation: 2202
I'm working with the Amazon API. I need to convert local time (EDT) to a DateTime that complies with the following documentation from Amazon:
You can specify the FulfillmentDate with or without time zone information: 2006-12-11T09:50:00 - local time zome applies 2006-12-11T09:50:00+02:00 - GMT time zone applies For locales affected by Daylight Saving Time, adjust the information, if necessary. Daylight Saving Time is not automatically taken into consideration.
I thought I needed to do something like shown in this SO thread, but apparently wrong, because when I upload the date using that method, Amazon shows it as a day before. I can confirm this by using this online converter tool.
For example:
My local time is "7/25/2012 00:00:00" (EDT).
Using above SO method, and formatted, it's now "2012-07-25T01:00:00-04:00".
But it converts to the 24th, specifically "Tuesday, July 24, 2012 at 21:00:00".
Obviously I'm doing something wrong here - I'd appreciate if someone can enlighten me.
Thank you!
Upvotes: 0
Views: 2046
Reputation: 1998
Obviously Amazon converts your local time information back to UTC time (which is based on your input 4 hours back in time: Tuesday, July 24, 2012 at 21:00:00 and therefore correct).
Which result have you been expected?
Upvotes: 1
Reputation: 3835
I would recommend using:
String xmlDateString = XmlConvert.ToString(DateTime.UtcNow,XmlDateTimeSerializationMode.Local);
Upvotes: 1
Reputation: 1361
I think I can introduce a "joda time" project written by Jon Skeet. You can refer to link pros and cons of joda time
Upvotes: 0