Ejemplo n.º 1
0
function weeks_in_year($year)
{
    // This is true for ISO, not US
    if (day_of_week_start() == 1) {
        return date("W", mktime(0, 0, 0, 12, 28, $year));
    }
    // else
    return ceil((day_of_week(1, 1, $year) + days_in_year($year)) / 7.0);
}
Ejemplo n.º 2
0
function days_between($ts1, $ts2)
{
    // First date always comes first
    if ($ts1 > $ts2) {
        return -days_between($ts2, $ts1);
    }
    // If we're in different years, keep adding years until we're in
    //   the same year
    if (date('Y', $ts2) > date('Y', $ts1)) {
        return days_in_year($ts1) + days_between(add_years($ts1, 1), $ts2);
    }
    // The years are equal, subtract day of the year of each
    return date('z', $ts2) - date('z', $ts1);
}