To Fix ValueError: time data does not match format ‘%Y-%m-%d %H:%M:%S.%f’ Error just Use the dateutil library. Here to solve this error just use the dateutil library and you can get the solution you want. So just try this. It will help you! >>> from dateutil import parser >>> s= '12 March, 2022, 3:50, pm, IST' >>> parser.parse(s) datetime.datetime(2022, 3, 12, 15, 50)