Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get Total of dateTime

How can I calculate the datetime for these strings:

  1. offline_dt = "Jan 31 23:01:43"
  2. offline_dt = "Feb 1 01:19:01" (there are 2 spaces between Feb and 1)

I tried this code, however I only the first one worked:

offline_dt = dt.datetime.strptime(offline,"%b %d %H:%M:%S")
like image 331
Barak Rosenfeld Avatar asked Dec 08 '25 05:12

Barak Rosenfeld


1 Answers

You could convert double spaces into a single space before processing.

offline.replace("  ", " ")
like image 60
Parsa Avatar answered Dec 10 '25 12:12

Parsa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!