date time arithmatic

Dave Pawson dpawson at nearlynildram.co.uk
Sun Jan 5 16:19:25 CET 2003


"Lexy Zhitenev" <zhitenev at cs.vsu.ru> wrote 
> 
> If the dates you operate on are in the Unix Epoch (1970 - 2038), you
> can use "time.mktime" function.
> 
>>>> import time
>>>> def now(d, m, y):
> ...          return int(time.mktime(d, m, y, 0, 0, 0, 0, 0, 0) / 86400)
> # 86400 - number of seconds passed since 1970/1/1.

That's it... (once I changed the parameter to a tuple :-)

Many thanks.

DaveP.




More information about the Python-list mailing list