Python Forum
Convert to UTC without changing time
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Convert to UTC without changing time
#1
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)
Reply
#2
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'))
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Convert looping home security to a one time scan of switches and sensors duckredbeard 0 1,749 Dec-08-2020, 04:31 AM
Last Post: duckredbeard
  Convert quarterly time series to monthly time series donnertrud 1 5,167 May-22-2020, 10:16 AM
Last Post: pyzyx3qwerty
  Convert weekly sequences to date and time. SinPy 0 1,441 Nov-23-2019, 05:20 PM
Last Post: SinPy
  Parse Binary Data File and convert Epoch Time drdevereaux 1 3,169 May-16-2019, 01:56 AM
Last Post: Larz60+
  Convert Column To Time Talch 1 2,659 Aug-16-2018, 03:02 PM
Last Post: mlieqo
  Convert from datetime to time.struct_time object chris0147 0 4,358 Mar-11-2018, 12:01 AM
Last Post: chris0147
  Time Difference in Epoch Microseconds then convert to human readable firesh 4 11,619 Feb-27-2018, 09:08 AM
Last Post: firesh
  Convert from time.struct_time to a string chris0147 2 7,735 Feb-22-2018, 04:53 PM
Last Post: chris0147

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020