0

I have a script that needs utc as an input:

This gives me the time format I need, but the wrong time:

time = datetime.datetime.utcnow().isoformat() + 'Z'

I want to be able to set the time in a format like this but have it output in utc.

time = datetime.datetime(2020, 4, 20, 12, 0, 0)

1 Answers1

0

How about

time = datetime.datetime(2020, 4, 20, 12, 0, 0).isoformat() + 'Z'

Here is more conversation about the topic: Generate RFC 3339 timestamp in Python

ex4
  • 2,289
  • 1
  • 14
  • 21