script for seconds in given month?

Alex Martelli aleax at
Tue Apr 17 06:41:00 CEST 2007

edfialk <edfialk at> wrote:

> Hi, does anyone happen to know of a script that would return the
> number of seconds in a month if I give it a month and a year?
> My python is a little weak, but if anyone could offer some suggestions
> I think I could handle it myself, or if anyone happens to know of a
> script already written that performs this I would be extremely
> grateful.

import calendar

def seconds_in_month(month, year):
    nomatter, daysinmonth = calendar.monthrange(year, month)
    return daysinmonth * 24 * 60 * 60


More information about the Python-list mailing list