Convert to UTC without changing time - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Convert to UTC without changing time (/thread-30784.html) |
Convert to UTC without changing time - pythonlearner1 - Nov-05-2020 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) RE: Convert to UTC without changing time - pythonlearner1 - Nov-05-2020 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')) |