Time

Chris Liechti cliechti at gmx.net
Mon Jun 3 18:22:00 EDT 2002


Gold Fish <occeanlinux at linuxmail.org> wrote in
news:3cfbdf0c_1 at news.iprimus.com.au: 

> Anyone know how to determine the time in python. If the mtime in the
> file filename.py is Mon Jun 3 03:25:57 2002 ,if i want to set the time
> forward or backwards in 5 days time, how can i do that. 

the "time" module has various functions to manipulate times in varous 
formats.

to add an offset, convert to seconds since epoch, manipulate and convert 
back:

>>> time.strftime("%a, %d %b %Y %H:%M:%S",
...    time.localtime(time.time()+24*3600*5))

chris

-- 
Chris <cliechti at gmx.net>




More information about the Python-list mailing list