src/util/Date.php
public static function days($month, $year = null) {
        static $months;

        if (!isset($year)) {
            // Use the current year by default
            $year = date('Y');
        }

        // Always integers
        $month = (int)$month;
        $year = (int)$year;

        // We use caching for months, because time functions are used
        if (empty($months[$year][$month])) {
            // Use date to find the number of days in the given month
            $total = date('t', mktime(1, 0, 0, $month, 1, $year)) + 1;

            $months[$year][$month] = array();
            for ($i = 1; $i < $total; $i++) {
                $months[$year][$month][$i] = (string)$i;
            }
        }

        return $months[$year][$month];
    }
public static function days($month, $year = null) {
        static $months;

        if (!isset($year)) {
            // Use the current year by default
            $year = date('Y');
        }

        // Always integers
        $month = (int)$month;
        $year = (int)$year;

        // We use caching for months, because time functions are used
        if (empty($months[$year][$month])) {
            // Use date to find the number of days in the given month
            $total = date('t', mktime(1, 0, 0, $month, 1, $year)) + 1;

            $months[$year][$month] = array();
            for ($i = 1; $i < $total; $i++) {
                $months[$year][$month][$i] = (string)$i;
            }
        }

        return $months[$year][$month];
    }
Number of days in a given month and year. Typically used as a shortcut
for generating a list that can be used in a form.

Date::days(4, 2010); // 1, 2, 3, ..., 28, 29, 30

@param   integer $month number of month
@param   integer $year number of year to check month, defaults to the current year
@return  array   A mirrored (foo => foo) array of the days.