Location: PHPKode > scripts > WebWidgets > webwidgets/example1_calendar.php
<?php
/**
 * Simple example how WebWidgets can be used
 */
$start = utime();
include './Base.lib.php';

$Html = new Bin('html');
$Head = new Bin('head');
$Title = new Bin('title');
$Title->add(new CData('Simple calendar on '.date('F')));
$Head->add($Title);
$Html->add($Head);

$Body = new Bin('body');
$Body->setAttr('bgcolor', '#f1edc7');

$Table = new Table(7);
$Table->setAttr(array('border'=>1, 'cellpadding'=>2, 'cellspacing'=>1));

$Table->add(new CData(date('d F Y')), '', '', array('colspan'=>7), 'th');

$week_days = array(1=>'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun');

$Table->setCellAttr('bgcolor', 'yellow');

for ($i=1; $i<=sizeof($week_days); $i++) {
	$Table->add(new CData($week_days[$i]));
}

$Table->setCellAttr('bgcolor', '#dee3e7');

list($num_days, $month, $year) = explode('-', date('t-m-Y')); 
$first_wd = strftime('%u', mktime(0,0,0, $month,1,$year));

if ($first_wd > 1) 
	$Table->add(new CData('&nbsp;'), '','', array('bgcolor'=>'#dee3e7', 'colspan'=>$first_wd-1));

for ($i=1; $i<=$num_days; $i++) {
	$Table->add(new CData($i));
}

$Body->add($Table);
$Html->add($Body);
$Html->view();


echo "<br>Page create in: ".(utime()-$start)." sec.<br>";

function utime ()
{
    $time = explode( " ", microtime());
    $usec = (double)$time[0];
    $sec = (double)$time[1];
    return $sec + $usec;
}


?>
Return current item: WebWidgets