Rivka
Rivka

Reputation: 2202

Local to GMT DateTime Conversion

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:

Obviously I'm doing something wrong here - I'd appreciate if someone can enlighten me.

Thank you!

Upvotes: 0

Views: 2046

Answers (3)

Oliver Vogel
Oliver Vogel

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

Steen Tøttrup
Steen Tøttrup

Reputation: 3835

I would recommend using:

String xmlDateString = XmlConvert.ToString(DateTime.UtcNow,XmlDateTimeSerializationMode.Local);

Upvotes: 1

cat916
cat916

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

Related Questions