image
Inicio » PHP » Biblioteca de Código PHP » Biblioteca de código

Formateado, conversiones y fechas

Calendario pequeño

Calendario pequeño y configurable.

Versión: 1.5
Fecha: 02/02/2002
Puntación: [2.9/5] Puntuar
  Volver Volver

Código

<?PHP
##InstaCalendar
##Written by Marcos Ojeda 11.July.2000
#Fill in default,today values accordingly as well as font...
#$month can be changed, but not $textmonth
## "Remember who loves you, baby!" --Kojack
$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());
$monthnames = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
$textmonth = $monthnames[$month - 1];
$year = (isset($year)) ? $year : date("Y",time());
$today = (isset($today))? $today : date("j", time()); ## Make $today really big to avoid hilite
$today = ($month == date("n",time())) ? $today : 32;
if ( (($month < 8) && ($month % 2 == 1)) || (($month > 7) && ($month % 2 == 0)) )
$days = 31;
if ( (($month < 8) && ($month % 2 == 0)) || (($month > 7) && ($month % 2 == 1)) )
$days = 30;
if ($month == 2)
$days = (date("L",time())) ? 29 : 28;

$dayone = date("w",mktime(1,1,1,$month,1,$year));
$daylast = date("w",mktime(1,1,1,$month,$days,$year));
?>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td bgcolor="<?PHP echo $defaultbgcolor ?>" colspan="7" valign="middle" align="center"><font color="<?php echo $monthcolor ?>" face="Arial, Helvetica, sans-serif" size="3"><b><?PHP echo $textmonth ?></b></font></td>
</tr>
<tr>
<td bgcolor="<?PHP echo $defaultbgcolor ?>" valign="middle" align="center" width="15%"><font face="<?PHP echo $fontfamily ?>" size="1"><b>Sun</b></font></td>
<td bgcolor="<?PHP echo $defaultbgcolor ?>" valign="middle" align="center" width="14%"><font face="<?PHP echo $fontfamily ?>" size="1"><b>Mon</b></font></td>
<td bgcolor="<?PHP echo $defaultbgcolor ?>" valign="middle" align="center" width="14%"><font face="<?PHP echo $fontfamily ?>" size="1"><b>Tue</b></font></td>
<td bgcolor="<?PHP echo $defaultbgcolor ?>" valign="middle" align="center" width="14%"><font face="<?PHP echo $fontfamily ?>" size="1"><b>Wed</b></font></td>
<td bgcolor="<?PHP echo $defaultbgcolor ?>" valign="middle" align="center" width="14%"><font face="<?PHP echo $fontfamily ?>" size="1"><b>Thu</b></font></td>
<td bgcolor="<?PHP echo $defaultbgcolor ?>" valign="middle" align="center" width="14%"><font face="<?PHP echo $fontfamily ?>" size="1"><b>Fri</b></font></td>
<td bgcolor="<?PHP echo $defaultbgcolor ?>" valign="middle" align="center" width="15%"><font face="<?PHP echo $fontfamily ?>" size="1"><b>Sat</b></font></td>
</tr>
<?PHP
if($dayone != 0)
$span1 = $dayone;
if(6 - $daylast != 0)
$span2 = 6 - $daylast;

for($i = 1; $i <= $days; $i++):
$dayofweek = date("w",mktime(1,1,1,$month,$i,$year));
$width = "14%";

if($dayofweek == 0 || $dayofweek == 6)
$width = "15%";

if($i == $today):
$fontcolor = $todayfontcolor;
$bgcellcolor = $todaybgcolor;
endif;
if($i != $today):
$fontcolor = $defaultfontcolor;
$bgcellcolor = $defaultbgcolor;
endif;

# if($i == putdayhere): #use this for *special* days of the month, can be set ahead as well w/ &&...
# $fontcolor = puthexcolorhere;
# $bgcellcolor = puthexcolorhere;
# endif;

if($i == 1 || $dayofweek == 0):
echo " <tr bgcolor="$defaultbgcolor">
";
if($span1 > 0 && $i == 1)
echo " <td align="left" bgcolor="$defaultbgcolor" colspan="$span1"><font face="null" size="1">&nbsp;</font></td>
";
endif;
/*Save this until supported
<td valign="middle" align="center" width="<?PHP echo $width ?>" style="background:<?PHP echo $bgcellcolor ?>;font-family:<?PHP echo $fontfamily ?>;color:<?PHP echo $fontcolor ?>;font-size:7pt"><?PHP echo $i ?></td>
*/
?>
<td bgcolor="<?PHP echo $bgcellcolor ?>" valign="middle" align="center" width="<?PHP echo $width ?>"><font color="<?PHP echo $fontcolor ?>" face="<?PHP echo $fontfamily ?>" size="1"><?PHP echo $i ?></font></td>
<?PHP
if($i == $days):
if($span2 > 0)
echo " <td align="left" bgcolor="$defaultbgcolor" colspan="$span2"><font face="null" size="1">&nbsp;</font></td>
";
endif;
if($dayofweek == 6 || $i == $days):
echo " </tr>
";
endif;
endfor;
?>
</table>


Ejemplo

Ir al ejemplo

  Volver Volver







Comparte



 
Valid HTML 4.01!
Última modificación:31 de Agosto de 2017. Spain - Espa�a.
© 1998-2004 por . Todos los derechos reservados.