Q:

Establishing month length and first day

Is there a simple way of, given a month and a year, establishing:

How many days there are in that month (factoring in leap years) Done
What day of the week the first day fall upon?

A:

See http://php.net/manual/en/function.cal-days-in-month.php
$num = cal_days_in_month(CAL_GREGORIAN, 8, 2003); // 31

and weekdays:
$weekday = date("l", mktime(0,0,0,$month,$day,$year));
$print ($weekday);

The latter is not very efficient but seems nicer than using getdate:
$my_t=getdate(date("U"));
print("$my_t[weekday], $my_t[month] $my_t[mday], $my_t[year]");

Output like
Wednesday, September 29, 2011

