0

I am reading a CSV file in Python. In one of the columns, the date is given in a format and I want to convert it to a different one as shown below.

Input - 15th November 2016 11:00pm
Output - 2016-11-15 23:00:00
Pattu
  • 3,481
  • 8
  • 32
  • 41
  • 1
    http://stackoverflow.com/questions/2265357/parse-date-string-and-change-format – User_Targaryen Sep 23 '16 at 13:06
  • The difficult part in this would be getting the initial format, as I don't believe Python has a formatter for `st/nd/rd/th`, so you might need to replace this first and then use an initial format like `'%d %B %Y %I:%M%p'`. – Stephen B Sep 23 '16 at 13:10
  • Yeah. I was stuck at the first part. But I thought there must be some library or Pythonic way to do that. – Pattu Sep 23 '16 at 13:27

1 Answers1

1

You'd be looking for something like this, I had a look through and it covers most of what your looking for. I'd write the code, but I'm on my phone, and phone coding ain't fun with a tiny keyboard.

https://www.tutorialspoint.com/python/time_strptime.htm