【问题标题】:Amazon MWS Orders API Timestamp Issue C#亚马逊 MWS 订单 API 时间戳问题 C#
【发布时间】:2018-08-21 17:09:39
【问题描述】:

我正在研究 Amazon Marketplace Web Services Orders API。我最近下载了 C# 的 MWS 订单 API。 Amazon api 需要 ISO8601 格式的时间戳 (yyyy-MM-dd'T'hh:mm:ss'Z')。

request.CreatedAfter = new DateTime();

这里的 request.CreatedAfter 是一个日期时间对象。如何将其设置为 ISO8601 日期时间?

【问题讨论】:

    标签: c# amazon amazon-mws iso8601


    【解决方案1】:

    CreatedAfter 是 DateTime 对象,所以不能在其中使用 datetime 字符串。

    尝试使用类似的东西,假设您需要在过去 3 小时内创建的订单

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

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

    仅供参考:您不能在 request.CreatedBefore 中使用 DateTime.UtcNow。它应该至少比当前时间早 2 分钟。您必须使用 UTC 时间。

    【讨论】:

    • 前 2 分钟是知识点,谢谢告知
    【解决方案2】:

    使用这个:

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

    结果:

    2018-08-23T08:21:51Z
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-04-28
      • 1970-01-01
      • 2013-05-27
      • 1970-01-01
      • 2011-11-26
      • 2012-12-03
      • 1970-01-01
      相关资源
      最近更新 更多