|
|
|
|
|
|
| |
Displays a nice little calendar and lets the user page back and forth between the months. The current day can be highlighted in a particular colour by setting the TODAYCOLOUR constant at the beginning of the calendar() function.
| <?php
/*
Description: Calendar
Author: Murray Moffatt for A Web 4 U Designs
History:
2004-06-20 : Initial coding.
2005-02-18 : Make stand-alone and include sample call for
publishing on WeberDev.com.
*/
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Calendar</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="author" content="A Web 4 U Designs - www.aweb4u.co.nz">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<?php
$month = $_GET["month"];
$year = $_GET["year"];
if (!isset($month) or !isset($year)) {
// Default to current month and year
list($month, $year) = explode("-", date("n-Y"));
}
calendar($month, $year);
function calendar($month, $year) {
define("TODAYCOLOUR", "#FF0000");
// Get current day, month and year
list($current_day, $current_month, $current_year) = split("-", date("j-n-Y"));
// Calculate previous and next month and year
list($prev_month, $prev_year) = split("-", date("n-Y", mktime(0, 0, 0, $month - 1, 1, $year)));
list($next_month, $next_year) = split("-", date("n-Y", mktime(0, 0, 0, $month + 1, 1, $year)));
echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\" align=\"center\">";
echo "<tr>";
echo "<td align=\"left\"><a href=\"{$_SERVER["PHP_SELF"]}?month=$prev_month&year=$prev_year\"><b>«</b></a></td>";
echo "<td colspan=\"5\" align=\"center\"><b>" . date("F, Y", mktime(0, 0, 0, $month, 1, $year)) . "</b></td>";
echo "<td align=\"right\"><a href=\"{$_SERVER["PHP_SELF"]}?month=$next_month&year=$next_year\"><b>»</b></a></td>";
echo "</tr>";
// Day names
echo "<tr>";
echo "<td><b>Sun</b></td>";
echo "<td><b>Mon</b></td>";
echo "<td><b>Tue</b></td>";
echo "<td><b>Wed</b></td>";
echo "<td><b>Thu</b></td>";
echo "<td><b>Fri</b></td>";
echo "<td><b>Sat</b></td>";
echo "</tr>";
// Insert empty cells so first day of the month starts under the correct day name
echo "<tr>";
$current_cell = date("w", mktime(0, 0, 0, $month, 1, $year));
if ($current_cell > 0) {
for ($i = 0; $i < $current_cell; $i++) {
echo "<td> </td>";
}
}
// Display the days
$totaldays = date("t", mktime(0, 0, 0, $month, 1, $year));
for ($day = 1; $day <= $totaldays; $day++) {
if ($current_year == $year and $current_month == $month and $current_day == $day) {
echo "<td align=\"center\" bgcolor=\"" . TODAYCOLOUR . "\"><b>$day</b></td>";
} else {
echo "<td align=\"center\">$day</td>";
}
$current_cell++;
if ($current_cell == 7) {
// At the end of the row
$current_cell = 0;
echo "</tr>";
if ($day < $totaldays) {
// Start a new row
echo "<tr>";
}
}
}
// Fill in the remaining days with blank cells
if ($current_cell > 0) {
$current_cell = 7 - $current_cell;
for ($i = 0; $i < $current_cell; $i++) {
echo "<td> </td>";
}
echo "</tr>";
}
echo "<tr>";
echo "<td colspan=\"7\" align=\"center\">";
echo "<a href=\"{$_SERVER["PHP_SELF"]}?month=$current_month&year=$current_year\">Goto Today</a>";
echo "</td>";
echo "</tr>";
echo "</table>";
}
?>
</body>
</html> | | |
|
| pcCalendar class - Allows for the creation of calendars in HTML pages. All output functions can be easily overridden, refer to article 1471 for an example.
Categories : PHP, Date Time, Calendar, PHP Classes | | | A PHP Calendar function with CSS : add a cool calendar to any php page by just adding a calendar class based function. Categories : PHP, PHP Classes, Calendar, Date Time | | | A simple and fast calendar combining PHP and tables. Use this as a base for applications in which a calendar is needed. Categories : Date Time, PHP, Complete Programs, Calendar | | | Example of using the pcCalendar class, article 1468 on weberdev.com. Calendar example. Categories : PHP, Date Time, PHP Classes, Calendar | | | Functions used to define a schedule of holidays. Can define non-fixed holidays (eg. 3rd sunday of June). Categories : Calendar, Date Time, PHP | | | Monthly and Daily Upcoming Events calendar. Categories : Date Time, PostgreSQL, PHP, Calendar, Databases | | | CALENDAR - easy calendar-navigation with PHP Categories : PHP, Date Time, HTML and PHP, Calendar | | | Calendars to choose a range of dates , reservation events ... Categories : PHP, Calendar, Java Script, Date Time | | | This script contains 2 functions: 1 to create html select object based on your own customer date format entry- "M d Y h:i.... etc". The second function processes the select object on submit back to unix time. Categories : PHP, Calendar, Date Time, HTML and PHP | | | Shows the current time as a PNG-image. This script does not use the GD
library. You can use it as a benchmark (because it's slow), or as a quick
reference for implementing a simple PNG-file generator. Categories : Graphics, Zlib, Calendar, PHP, Date Time | | | Simple PHP control CSS Calender Categories : PHP, HTML and PHP, Calendar, Date Time, CSS | | | enhanced date picker with jcript checking for a dynamic date input Categories : PHP, Java Script, Date Time, Calendar, Arrays | | | Calendar, Kalender, date, time, day, month, year Categories : PHP, Date Time, Calendar | | | Calendar class on the same page , suitable for reservation
Categories : PHP, Calendar, Date Time | | | function to generate calendars on the fly.
Categories : Calendar, PHP, Date Time | |
| | | | caballo negro wrote :1277
How to change the first day of the week to Monday and not to Sunday??
How to modify to see the weeknumbers of each week??
| |
|
|
|