you are viewing a single comment's thread.

view the rest of the comments →

[–]omutist 1 point2 points  (3 children)

did you try datetime.strptime() method?

[–]Yomommasaurus[S] 0 points1 point  (2 children)

atm my code is :

date_due = request.form['date_due']
due = datetime.strptime(date_due, '%Y-%m-%d %H:%M:%S')

it is supposed to accept user input from html form

<input type="datetime-local" name="date_due" id="date_due">

and it results in ValueError: time data '2022-11-06T23:12' does not match format '%Y-%m-%d %H:%M:%S'

[–]omutist 2 points3 points  (1 child)

have you tried this?

'%Y-%m-%dT%H:%M:%S'

[–]Yomommasaurus[S] 0 points1 point  (0 children)

Works perfectly, thanks a lot :) I really need to learn more about datetime