Commit 6f5f1ef3 authored by Dimitris Bozelos's avatar Dimitris Bozelos
Browse files

Issue #3307903 Added missing utility method

parent cb9e2bd7
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -136,4 +136,25 @@ class Utilities {
    ));
  }

  /**
   * Converts a Unix timestamp to an ISO 8601 date as expected by the SP-API.
   *
   * @param int $timestamp
   *   The Unix timestamp to convert.
   *
   * @return string
   *   The time in ISO 8601 format and in UTC timezone.
   *
   * @I Validate that the input is a Unix timestamp
   *    type     : bug
   *    priority : normal
   *    labels   : validation
   */
  public static function timestampToIso8601($timestamp) {
    $datetime = new \DateTime('now', new \DateTimeZone('UTC'));
    $datetime->setTimestamp($timestamp);

    return $datetime->format('Y-m-d\TH:i:s') . 'Z';
  }

}