00100001
00100001

Sundays_tween

Returns the number of Sundays between to valid dates.

function sundays_tween($sdate,$edate) {
    $from_date = strtotime($sdate);
    $to_date = strtotime($edate);
    $days = 0;
    while ($from_date < $to_date) {
        $from_date = strtotime('+1 day', $from_date);
        $day = date('D', $from_date);
        if ($day != 'Sun') {
            continue;
        }
        ++$days;
    }
    return $days;
}