Parsing a date string using datetime.strptime
such as:
from datetime import datetime
datetime.strptime('AUG21 3:26PM', '%b%d %I:%M%p')
Results in
1900-08-21 15:26:00
How can I write something similar in a Pythonic way so that, when there's no year in the date string, it takes the current year as default (e.g 2013) rather than 1900?
I've checked the documentation of the strftime
function and it doesn't have an option to change the default year. Maybe another time library can do so?