Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What time format is this?
#1
I'm working with an API that returns the time for events in this format:

2022-06-14T13:00:00-07:00

Can I presume that that's telling me local time with the UTC offset (-07:00) appended to it? Or would it be UTC with the offset included to produce local time?

This fails with "ValueError: 'z' is a bad directive in format '%Y-%m-%dT%H:%M:%S%z'":

datetime.datetime.strptime("2022-06-14T13:00:00-07:00", '%Y-%m-%dT%H:%M:%S%z')

I can chop off the offset easily enough, but I'm wondering if that's the best approach.

Thanks for any insights.
Reply


Messages In This Thread
What time format is this? - by wrybread - Jun-14-2022, 10:27 PM
RE: What time format is this? - by Larz60+ - Jun-14-2022, 10:42 PM
RE: What time format is this? - by Gribouillis - Jun-15-2022, 07:24 AM
RE: What time format is this? - by snippsat - Jun-15-2022, 02:46 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python date format changes to date & time 1418 4 697 Jan-20-2024, 04:45 AM
Last Post: 1418
Smile Set 'Time' format cell when writing data to excel and not 'custom' limors 3 6,397 Mar-29-2021, 09:36 PM
Last Post: Larz60+
  ValueError: time data 'None' does not match format '%Y-%m-%dT%H:%M:%S.%f' rajesh3383 4 14,828 Sep-03-2020, 08:22 PM
Last Post: buran
  how to retain time format in df.to_csv Mekala 2 3,239 Aug-07-2020, 07:04 AM
Last Post: buran
  getting error ValueError: time data '' does not match format '%H:%M' srisrinu 2 5,637 Apr-09-2020, 11:12 AM
Last Post: srisrinu
  Incorrect time format KoSik 5 3,099 Aug-15-2019, 05:10 PM
Last Post: KoSik
  Change Time Format in Python bluethundr 2 2,733 Mar-04-2019, 09:13 PM
Last Post: bluethundr
  Wrong or missing date format and time in mails sipriusPT 3 4,325 Aug-08-2017, 03:22 PM
Last Post: sipriusPT

Forum Jump:

User Panel Messages

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