# [Tutor] I need a time object from the future

Carlos Hanson carlos.hanson at gmail.com
Fri Oct 20 18:19:52 CEST 2006

```
On Fri, October 20, 2006 8:55 am, William O'Higgins Witteman wrote:
> I've been looking into this, and I am not understanding how to get
> this task done.  I need to be able to look at a time object and know
> if it si between now and a set point 120 days in the future.  I can
> get a value for now (currently I am using datetime.datetime.now()),
> but I haven't found a way to get now + 120 days, or figured out how
> to test if a given datetime falls between the two.  Any pointers
> would be appreciated. Thanks. --

The time() function returns the current time in seconds, so one idea
is adding the number of seconds for 120 days:

>>> from time import time, ctime
>>> help(time)
Help on built-in function time:

time(...)
time() -> floating point number

Return the current time in seconds since the Epoch.
Fractions of a second may be present if the system clock provides
them.
>>> t1 = time()
>>> t2 = t1 + 120*24*60*60
>>> now = time()
>>> now > t1 and now < t2
True
>>> ctime(t1)
'Fri Oct 20 09:09:26 2006'
>>> ctime(t2)
'Sat Feb 17 08:09:26 2007'
>>> ctime(now)
'Fri Oct 20 09:10:14 2006'

--
Carlos Hanson

```