Application built with: Python and Angular
I have a form that uses the following input to allow a user to insert a date:
<input type="datetime-local" id="clubJoined" name="clubJoined" class="date-input" formControlName="clubJoined">
And in my python backend I convert this string object into a date object using the following:
# - Club Joined
"club_joined": datetime.datetime.strptime(request.form["clubJoined"], '%y-%m-%d %H:%M')
But this gives me a formatting error:
ValueError: time data '2011-01-01T23:36' does not match format '%y-%m-%d %H:%M'
So I added the T
so that the conversation format looks like this:
# - Club Joined
"club_joined": datetime.datetime.strptime(request.form["clubJoined"], '%y-%m-%dT%H:%M')
But this gave me the following error:
ValueError: time data '2011-01-01T23:36' does not match format '%y-%m-%dT%H:%M'
How do I format this correctly?
%y
is the format code for a two-digit year;%Y
for a fully specified year.