Well, you need to read the manual for the php functions: one converts a set of values like Year, Month, Day into a "datestamp" value; the other extracts useful information from a datestamp, back into human readable form. For no reason that I can imagine, one of these functions is called "date" and the other "time" (the difference between them is not remotely connected to the difference between date and time, but hey, welcome to modern programming!)
http://jp.php.net/manual/en/function.date.phphttp://jp.php.net/manual/en/function.time.phpI assume you want a function like sundays($year, $month) that returns the number of sundays? So:
Get the timestamp for date $year - $month - 1
Get from it the day of the week (as a number, for convenience)
Subtract from 7 (plus-minus 1) to get the date of the first sunday.
Find the number of days in the month
Subtract the date of the first sunday (plus-minus 1), and divide by 7, rounding down (plus-minus 1).
This gives you the answer
You will need to be careful, because of all these (plus-minus 1) bits - the fact that you could probably easily have up to 3 one-off errors in either direction makes just using a random person's function alleged to do this to be a dubious proposition.