Yes, a format like 2012-12-11T00:00:00+00:00
is specified by ISO 8601 - see e.g. wikipedia/ISO8601 or C.4.2 Date and Time of ISO/TC154N, p.29.
From the comment section, it seems however that the AWS service (Kendra) expects a Z
for UTC (see also Kendra docs)
, instead of +00:00
as returned by the Python code. A simple work-around can be a string-replace:
datetime.fromtimestamp(<epochTimeHere>, timezone.utc).isoformat().replace('+00:00', 'Z')
Side note - Python offers a catch in the other direction as well, i.e. when parsing ISO 8601 timestamps: the built-in datetime.fromisoformat
method won't parse Z
to UTC, but only +00:00
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…