i'm not too familiar with the date()
Well, the way to get familiar is to study the manual page. For example, the list of format-characters in the date() manual page includes:
t - number of days in the given month; i.e. "28" to "31"
which is one of the things you need.
The day-of-week of the first of the month is more complicated. I don't know any way to get that other than the brute-force method of:
Get the current date, and split it into its components.
Create a new timestamp for the first of the month using mktime().
Now get the day-of-week of the first by using date() on the new
timestamp instead of the current date.