I know this has been asked but there was no solution provided there. Python UTC datetime object's ISO format doesn't include Z (Zulu or Zero offset)
I am looking for a clean way of generating UTC time stamp with this format in Python. The format I need is
2013-10-29T09:38:41.341Z
.
Specifically, I need to include "Z" at the end. Python's datetime.utcnow().isoformat()
does not append "Z" at the end.
Note that manually appending "Z" is not a solution I can accept. I am looking for a clean way to do this.
What is the clean way to generate UTC timestamp in ISO format with the suffix Z
?
How about something like
datetime.utcnow().isoformat()[:-3] + 'Z'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With