Calculate Number of Days, Excluding Sundays, Between Two Dates

I'm using this code to calculate the difference (number of days) between any two dates.
Both $begin_mk and $end_mk are in YYYY-mm-dd format, like 2008-06-19 .

How could I modify it to exclude Sundays from the calculation?

For example, if there are 90 calendar days from 2008-01-01 to 2008-03-31 , then I guess I need to:
1) calculate the number of Sundays between those two dates, and
2) subtract the number of Sundays from the total number of days (90, in this case)

How to calculate the number of Sundays between any two dates? Or is there some better, easier way to do this?

Open in new window