-
Simple PHP Calendar 1.11 description
Simple PHP Calendar 1.11 description
Simple PHP Calendar is a a simple, extensible PHP calendar class. The project focuses exclusively on generating an HTML representation for a given month. It is meant to be easily extended for use in other applications, such as input widgets for forms, or full event calendaring applications. Its output is completely customizable via CSS.
A simple example
After downloading the class and including it in your PHP script, youre ready to start using it. The constructor requires two paramets, a year and month. The following code produces a very plain looking calendar.
1 require_once( class.Calendar.php );
2 $cal = new Calendar (2004, 3 );
3 echo "".$cal->getFullMonthName().
4 echo $cal->display();
Customizing the display
You can use two methods to change how the calendar is displayed. Use setTableWidth to define how wide to make the table, in pixels or as a percentage of the screen. Use setDayNameFormat to change how weekdays are displayed in the header row using strftime formats.
1 require_once(class.Calendar.php);
2 $calendar = new Calendar (2004, 4);
3 $calendar->setTableWidth(50%);
4 $calendar->setDayNameFormat(%A);
5 echo "".$calendar->getBriefMonthName().
6 echo $calendar->display();
You can use CSS selectors to control the formatting of all aspects of the calendar, including adding borders and how empty boxes display. Lets wrap our talbe in a div named calendar and use the following styles.
overall table
#calendar table {
border:1px solid #fff;
padding: 0;
margin:20px;
``````
/* the day headers across the top
#calendar th {
background: #565;
color: #fff;
margin: 3px;
padding: 2px 5px;
``````
/* how days this month will look, make dates appear in top right
#calendar td {
background: #eee;
color: #000;
padding: 2px;
margin:0;
height:60px;
text-align:right;
vertical-align:top;
border:1px solid #fff;
/* these are the days falling outside this month */
#calendar td.notInMonth {
background: #999;
`````
Enhancements:
- The documentation has been polished.
- An example has been added for extending the class to customize how a calendar grid will display.

BizHat.com - Health
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks