Person's age in seconds


#1


Hello how do i use date.time to find out how many seconds i have been alive for


#2

timedelta

An example using days between two dates can be seen here.

To calculate seconds, multiply by 86400 (24 * 3600).

Consider,

>>> from datetime import date
>>> from datetime import timedelta
>>> today = date.today()
>>> xmas = date(2016, 12, 25)
>>> x = xmas - today
>>> x
datetime.timedelta(90)
>>> str(x)
'90 days, 0:00:00'
>>> int(str(x).split(' ')[0])
90
>>> x.days
90
>>> x.days * 86400
7776000
>>>

That's how many seconds till Christmas,


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.