0
[PYTHON] How can i import datetime?
How does it work? Thanks for answering! ;)
3 Réponses
+ 1
if you have your birthday as datetime just subtracting with current datetime will give you the age
import datetime
birthday=datetime.datetime.strptime('Jun 1 2005 1:33PM', '%b %d %Y %I:%M%p')
age=datetime.datetime.now()-birthday
+ 3
Its simple. To print current datetime
import datetime
print datetime.datetime.now()
0
Thanks! And, if i want to make an age calculator with the current datetime? For example to calculate the days: current datetime*365?