This tutorial will show you how to render a calendar for the current month using PHP and HTML. This tutorial makes use of PHP's
calendar functions - you must have these installed for the code to work. For more information visit the calendar section on
PHP website.
If you want to get the complete source right away click here.
To render the calendar we need the current month and year (expressed as integers). Using PHP's calendar functions we can determine
the variables we need to render the calendar: the number of days in the month and the start day. The function jddayofweek() allows you
to get a day as an integer and the jdmonthname() converts the month to a word.
Now the guts of rendering the calendar. We need to work out from the start day how many empty cells the
calendar must start off with. Then we render each day as a cell; every seven cells we start a new row. Finally, we clean up by
working out how many empty cells we need to complete the current row.
And finally here's the complete working code. If you want render a calendar for any given month or any given year simply override
the $thismonth and $thisyear variables.
These resources are provided free of charge. If, however, you would like to make a donation to help finance these resources, no matter how big or small, please use the PayPal
button below.
Credits
This resource was written by Tim Bennett Bsc (Hons). Tim Bennett has a First Class Degree in
Multimedia Systems Computing
from Leeds Metropolitan University. He works as a freelance multimedia developer under the company name
Texelate creating free and
commissioned
high-quality multimedia solutions. Find out more by visiting the portfolio section and viewing his blog. If
you'd like to request a resource get in touch!
Rate this Resource
Click on the appropriate star below to rate this resource:
http://apps.facebook.com/savemyprofile/