Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Incorrect time format
#1
Hello,
I have a problem with the time format.

Function excerpt:

format = '%H:%M:%S.%f'
aktual=datetime.datetime.now().time()
 
try:
        timeON = datetime.datetime.strptime(str(aktual), format) - datetime.datetime.strptime(lampaTV.AutoON, format)
except ValueError as e:
        print('Time error1:', e)
This function is called about 4 times per second and works well but after 2-4 days it throws an error e.g.
Quote:ValueError("time data '20:42:11' does not match format '%H:%M:%S.%f'",))

I can't deal with it for a long time Confused
Reply


Messages In This Thread
Incorrect time format - by KoSik - Aug-14-2019, 05:30 PM
RE: Incorrect time format - by ichabod801 - Aug-14-2019, 06:59 PM
RE: Incorrect time format - by snippsat - Aug-14-2019, 07:19 PM
RE: Incorrect time format - by buran - Aug-14-2019, 07:21 PM
RE: Incorrect time format - by perfringo - Aug-14-2019, 07:47 PM
RE: Incorrect time format - by KoSik - Aug-15-2019, 05:10 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python date format changes to date & time 1418 4 605 Jan-20-2024, 04:45 AM
Last Post: 1418
  Code is returning the incorrect values. syntax error 007sonic 6 1,227 Jun-19-2023, 03:35 AM
Last Post: 007sonic
  What time format is this? wrybread 3 2,086 Jun-15-2022, 02:46 PM
Last Post: snippsat
  error 1102 (42000) incorrect database name 's' Anldra12 4 1,710 Jun-08-2022, 09:00 AM
Last Post: Anldra12
  openpyxl incorrect delete rows VladislavM 6 4,119 Jul-19-2021, 08:54 AM
Last Post: VladislavM
  Incorrect Type Error milkycow 4 2,905 Jun-25-2021, 06:04 AM
Last Post: milkycow
Smile Set 'Time' format cell when writing data to excel and not 'custom' limors 3 6,298 Mar-29-2021, 09:36 PM
Last Post: Larz60+
  Why is 0.1 * 0.2 arithmetically incorrect? Pedroski55 2 2,226 Nov-25-2020, 12:01 AM
Last Post: snippsat
  ValueError: time data 'None' does not match format '%Y-%m-%dT%H:%M:%S.%f' rajesh3383 4 14,573 Sep-03-2020, 08:22 PM
Last Post: buran
  how to retain time format in df.to_csv Mekala 2 3,166 Aug-07-2020, 07:04 AM
Last Post: buran

Forum Jump:

User Panel Messages

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