I am writing something to where the user puts in a date. Then it would compare the date input by the user and is subtracted by current date. Is there some code I can use for python ask the user for the date? And is there a way I can have python check the date on device it is on? Thanks Iām advance.
Asked
Active
Viewed 40 times
0
-
Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. ā Community Jul 12 '22 at 09:07
1 Answers
0
Here is how to ask user for a date:
from datetime import datetime
usr_input = str(input('Enter date(yyyy-mm-dd): '))
usr_date = datetime.strptime(usr_input, "%Y-%m-%d")
print(usr_date)
You might find this link useful in getting current date and time: https://phoenixnap.com/kb/get-current-date-time-python
Also you could check this post: How to get the Date and Time of Current Location in Python

Sabsa
- 191
- 9