Zend - The PHP Company




Calendars

Add Code


An itty bitty calendar  

Type: application
Added by: khoker
Entered: 17/09/2001
Last modified: 09/12/2000
Rating: **** (5 votes)
Views: 12775
Same as "A Tiny Calendar" which I saw on the top 10 requested list, just less code. Give it a month/day/year, and it will generate the calendar and highlight the day. Colors are customizeable. If no date arguments given, assumes today.


<?
## mail:  kghoker at yahoo.com  9/17/2001
## Much like "A Tiny Calendar", just less code.  
## Give it a month/day/year, and it will generate the calendar and highlight the day.  
## Colors are customizeable.  If no date arguments given, assumes today.

  
$fontfamily = isset($fontfamily) ? $fontfamily "Tahoma, Geneva, sans-serif"
  
$defaultfontcolor = isset($defaultfontcolor) ? $defaultfontcolor "#000000"
  
$defaultbgcolor = isset($defaultbgcolor) ? $defaultbgcolor "#FFFFFF"
  
$todayfontcolor = isset($todayfontcolor) ? $todayfontcolor "#FFFFFF"
  
$todaybgcolor = isset($todaybgcolor) ? $todaybgcolor "#CC0000"
  
$monthcolor = isset($monthcolor) ? $monthcolor "#333399"
  
$relfontsize = isset($relfontsize) ? $relfontsize "1"
  
$cssfontsize = isset($cssfontsize) ? $cssfontsize "8pt"

  
$month = (isset($month)) ? $month date("n",time()); 
  
$year = (isset($year)) ? $year date("Y",time()); 
  
$today = (isset($today))? $today date("j"time()); 

  
$numdays date("t",mktime(1,1,1,$month,1,$year));
  
$wdays = array('Sun','Mon','Tue','Wed','Thu','Fri','Sat');

print(
"<table border='0' cellpadding='0' cellspacing='0' width='150'>n<tr>n");
print(
"<td bgcolor='{$defaultbgcolor}' colspan='7' valign='middle' align='center'><font color='{$monthcolor}' face='Arial, Helvetica, sans-serif' size='3'><b>" date("F",mktime(1,1,1,$month,1,$year)) . "</b></font>n</td>n");
print(
"</tr>n<tr>n");
foreach(
$wdays as $value) {
  print(
"<td bgcolor='{$defaultbgcolor}' valign='middle' align='center' width='15%'><font face='{$fontfamily}' size='1'><b>{$value}</b></font></td>n"); 
}
print(
"</tr>n<tr>n");
for (
$i 0$i $dayone date("w",mktime(1,1,1,$month,1,$year)); $i++) {
  print(
"<td bgcolor='{$bgcellcolor}' valign='middle' align='center' width='{$width}'><font color='{$fontcolor}' face='{$fontfamily}' size='1'>&nbsp;</font></td>n");
}
for (
$zz 1$zz <= $numdays$zz++) {
  if (
$i >= 7) {  print("</tr>n<tr>n"); $i=0;  }
  if (
$zz == $today) {
    print(
"<td bgcolor='{$todaybgcolor}' valign='middle' align='center' width='{$width}'><font color='{$todayfontcolor}' face='{$fontfamily}' size='1'>{$zz}</font></td>n");
  } else {
    print(
"<td bgcolor='{$bgcellcolor}' valign='middle' align='center' width='{$width}'><font color='{$fontcolor}' face='{$fontfamily}' size='1'>{$zz}</font></td>n");
  }
  
$i++;
}  
print(
"</tr>n"); 
print(
"</table>n");
?>


Usage Example




Rate This Script





Search



This Category All Categories