0

[PYTHON] How can i import datetime?

How does it work? Thanks for answering! ;)

14th Mar 2018, 8:08 PM
Gergo Starosta
Gergo Starosta - avatar
3 Answers
+ 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
14th Mar 2018, 8:39 PM
Pavan Kumar T S
Pavan Kumar T S - avatar
+ 3
Its simple. To print current datetime import datetime print datetime.datetime.now()
14th Mar 2018, 8:23 PM
Pavan Kumar T S
Pavan Kumar T S - avatar
0
Thanks! And, if i want to make an age calculator with the current datetime? For example to calculate the days: current datetime*365?
14th Mar 2018, 8:32 PM
Gergo Starosta
Gergo Starosta - avatar