The output of datetime.datetime.now()
is output in my UTC-8 timezone. I would like to convert this to an appropriate timestamp with tzinfo UTC.
from datetime import datetime, tzinfo x = datetime.now() x = x.replace(tzinfo=UTC)
^ output NameError: name 'UTC' not defined
x.replace(tzinfo=<UTC>)
displays syntax x.replace(tzinfo=<UTC>)
: invalid syntax
x.replace(tzinfo='UTC')
output TypeError: the tzinfo argument must be None or a subclass of tzinfo, not type 'str'
What is the correct syntax to execute my example?
source share