calendar() displays a calendar page of the chosen month and year. The function takes a date array (as returned by getDate) as its only parameter. If this one is omitted, the calendar will default to the date on the server.

This is the PHP version of calendar.php. The translation was done line by line, which is a testament to how similar PHP and JavaScript can be.