Source for file 14.php
Documentation is available at 14.php
* Description: same as 3.php, but using the PEAR::Date engine
* Note: make sure PEAR::Date is a stable release!!!
return ((float) $usec + (float) $sec);
// Switch to PEAR::Date engine
define('CALENDAR_ENGINE', 'PearDate');
if (!@include 'Calendar'.DIRECTORY_SEPARATOR. 'Calendar.php') {
define ('CALENDAR_ROOT','../../');
require_once CALENDAR_ROOT. 'Month/Weekdays.php';
require_once CALENDAR_ROOT. 'Day.php';
// Initialize GET variables if not set
if (!isset ($_GET['y'])) $_GET['y'] = date('Y');
if (!isset ($_GET['m'])) $_GET['m'] = date('m');
if (!isset ($_GET['d'])) $_GET['d'] = date('d');
// Create an array of days which are "selected"
// Used for Week::build() below
// Build the days in the month
$month->build ($selectedDays);
// Construct strings for next/previous links
$PMonth = $month->prevMonth ('object'); // Get previous month as object
$prev = $_SERVER['PHP_SELF']. '?y='. $PMonth->thisYear (). '&m='. $PMonth->thisMonth (). '&d='. $PMonth->thisDay ();
$NMonth = $month->nextMonth ('object');
$next = $_SERVER['PHP_SELF']. '?y='. $NMonth->thisYear (). '&m='. $NMonth->thisMonth (). '&d='. $NMonth->thisDay ();
$thisDate = new Date ($month->thisMonth ('timestamp'));
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<title> Calendar using PEAR::Date Engine </title>
background-color: silver;
background-color: yellow;
<h2>Calendar using PEAR::Date Engine</h2>
<?php echo $thisDate->format ('%B %Y'); ?>
while ($day = $month->fetch ()) {
// Build a link string for each day
$link = $_SERVER['PHP_SELF'].
// isFirst() to find start of week
if ($day->isSelected ()) {
echo '<td class="selected">'. $day->thisDay (). '</td>'. "\n";
} else if ($day->isEmpty ()) {
echo '<td> </td>'. "\n";
echo '<td><a href="'. $link. '">'. $day->thisDay (). '</a></td>'. "\n";
// isLast() to find end of week
<a href=" <?php echo $prev; ?>" class="prevMonth"><< </a>
<td colspan="5"> </td>
<a href=" <?php echo $next; ?>" class="nextMonth"> >></a>
echo '<p><b>Took: '. (getmicrotime()- $start). ' seconds</b></p>';
Documentation generated on Mon, 11 Mar 2019 15:37:47 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|