find difference in days from YYYYMMDD to YYYYMMDD

Zentrader zentraders at gmail.com
Sat Sep 22 21:10:52 CEST 2007


On Sep 22, 2:37 am, Konstantinos Pachopoulos <kostaspa... at yahoo.gr>
wrote:
> Hi,
> does any body now any such algorith? to find difference in days from
> YYYYMMDD to YYYYMMDD?
> Or just an algorithm, that converts YYYYMMDD to seconds since the epoch?
>
> Thanks

For some reason, to-seconds-since-epoch is in the calendar class.
calendar.timegm() takes a tuple and returns the epoch seconds
import time
import calendar

today_secs = calendar.timegm( (2007, 9, 22, 0, 0, 0) )
print today_secs
one_day = 24*60*60
print time.gmtime( today_secs+one_day )




More information about the Python-list mailing list