-1

I have a date string - "Fri Jun 05 15:59:14 PDT 2020" How to convert into datetime object?

i have tried below format, its not working.

'%a %b %d %H:%M:%S %Z %Y'
FObersteiner
  • 22,500
  • 8
  • 42
  • 72
Rehan Shikkalgar
  • 1,029
  • 8
  • 16
  • There may be an issue with your timezone abbreviation, I've used ```pytz``` library in the past, it could work for you as well – ekaeo Aug 19 '23 at 08:11

1 Answers1

1
from dateutil import parser

date_string = "Fri Jun 05 15:59:14 PDT 2020"
datetime_obj = parser.parse(date_string)

print(datetime_obj)

output:-

2020-06-05 15:59:14

try using parse to Converts the string representation of a date and time to its DateTime equivalent,

vegan_meat
  • 878
  • 4
  • 10