web blazonry web development scripts and tutorials Get best price on Prepaid Samsung Galaxy A10e
   PHP       Name Generators       Perl       CSS       Javascript       Java       MySql       How Tos       Resources   




PHP Name Generators
  Wu-Name
  U.S. Name
  Baby Name

Bookmark and Share




PHP: Web Calendar With Events

This coding example builds a calendar for the current month. It provides navigation to go backward or forward, month-by-month. Click a date to fill in a form to add an event.

Use the calendar with or without the "add event" feature. Building a calendar on-the-fly without other bells and whistles has its practical uses.

Take a look at the demo of the calendar before we discuss how it works.

Building the Calendar for the Current Month
First generate the calendar for the current month. Grab today's date. Then get the month and year. Create a new date of the first of the month. From this date you can figure out which day of the week it falls on.

Next, figure out the last day of the month. I loop through the days 28th - 32nd and create a new date out of it. Compare the current month to this new date's month. If it changed, the previous day was the last day of the month.

You then start on the first day, postitioning yourself over however many weekdays the first is in. Next, loop through all the days until the day reaches the end of the month. Keep track of the weekdays using modulus 7 to find the end of each week.

More Info About Calendars
PHP has some great date function capabilities such as built-in support for text months and days. Plus, it can even display the appropiate suffix on a day. ('st', 'nd' 'rd', 'th' in 1st, 2nd, 3rd 4th). View the source code and the PHP documentation to see how these functions are used.

I wrote a similar calendar in ASP. You can download the JScript ASP source code for that calendar below. Note it is different than the PHP version shown here.

View Event Calendar Demo


Download PHP Source Here (datemenu_php.phps)

Download ASP Source Here (datemenu_asp.txt)

 

Newest Pages
Test Google Ads Ver. 2
Free Linux Admin Books
Free Linux Books for Programmers
Free Books for Linux on the Desktop
Free PHP Books
Free JavaScript Books
Free Java Books - Advanced
Free Java Books - Basic
Free Perl Books
Free Python Books
Quote of the Day (PHP)
Debugging Part 2
How to Test Google Ads
Most Popular Pages
Baby Name Generator
U.S. Name Generator
Wu Name Generator
Popup Windows (JavaScript)
Upload and Resize an Image (PHP)
How To Install Apache + PHP + MySQL
Intro to Web Databases (PHP, MySQL)

Least Popular Pages
iNews Applet (Java)
Java Resources
Site Monitor (Perl)
PHP Resources
 
 

  privacy policy     ||     © 1997-2016. astonishinc.com   All Rights Reserved.