Python Forum

Full Version: Convert to UTC without changing time
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am pulling data from elasticsearch in d/m/yyyy format.

when it come I believe it is in UTC format. after some processing I am putting that data back in to Elasticsearch and it converts it to UTC and moves the time.

for example when I read the data it come as
2020-11-02 success monoexec 116477
2020-11-02 success paraexec 16300

but when I put that back in elasticsearch it becomes
2020-11-01 19:00.00 ( I don't want that)
used this to get what I wated

mytime_timestamp = datetime.strptime(mytime, "%Y-%m-%d")
datetime_obj_utc = mytime_timestamp.replace(tzinfo=timezone('Etc/UTC'))
datetime_obj_cst = mytime_timestamp.replace(tzinfo=timezone('America/Chicago'))