Parse datetime string in python ---> Fri Dec 01 2023 00:00:00 GMT 0530 (India Standard Time)

36 Views Asked by At

Trying this code snippet:-

from dateutil import parser as date_parser

print(date_parser.parse("Fri Dec 01 2023 00:00:00 GMT 0530 (India Standard Time)"))

Getting this error:-

raise ParserError("Unknown string format: %s", timestr)

dateutil.parser._parser.ParserError: Unknown string format: Fri Dec 01 2023 00:00:00 GMT +0530 (India Standard Time)
1

There are 1 best solutions below

0
Kastet6398 On

You need to remove GMT, use +0530 instead of 0530 (without +) and IST instead of Indian Standard Time. Here's the code:

from dateutil import parser as date_parser

print(date_parser.parse("Fri Dec 01 2023 00:00:00 +0530 (IST)"))