datetime | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

datetime

With the datetime library how do you get user input in the date format?

1st Jan 2021, 3:24 PM
Nathan Robertson
Nathan Robertson - avatar
2 Answers
+ 2
Simply get the user input as a string. Then use the datetime.datetime.strptime method to parse it as a datetime object https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior
1st Jan 2021, 3:36 PM
XXX
XXX - avatar
+ 2
your the best :)
1st Jan 2021, 3:37 PM
Nathan Robertson
Nathan Robertson - avatar