1
votes

I am working on Amazon Marketplace Web Services Orders API. I recently downloaded MWS Orders API for C#. Amazon api require timestamps in ISO8601 format (yyyy-MM-dd'T'hh:mm:ss'Z').

request.CreatedAfter = new DateTime();

Here request.CreatedAfter is a datetime object. How can I set it to ISO8601 datetime?

2

2 Answers

2
votes

CreatedAfter is DateTime object, so can't use datetime string in it.

try to use something like this, let's say you need orders created in last 3 hours

request.CreatedAfter = DateTime.UtcNow.AddHours(-3);

request.CreatedBefore = DateTime.UtcNow.AddMinutes(-2);

FYI: you can't use DateTime.UtcNow in request.CreatedBefore. it should be at least 2 minutes before current time. you have to use UTC time.

-1
votes

Use this :

String dateTime = DateTime.UtcNow.ToString("s") + "Z";

Result :

2018-08-23T08:21:51Z