Foros del Web » Programando para Internet » PHP »

Problema calendario

Estas en el tema de Problema calendario en el foro de PHP en Foros del Web. Hola tengo un calendario que cogi de una web pero el problema es que empezaba la semana en domingo, he estado haciendo variaciones para que ...
  #1 (permalink)  
Antiguo 11/03/2010, 06:44
 
Fecha de Ingreso: marzo-2009
Mensajes: 221
Antigüedad: 15 años, 1 mes
Puntos: 0
Problema calendario

Hola tengo un calendario que cogi de una web pero el problema es que empezaba la semana en domingo, he estado haciendo variaciones para que empezase en lunes pero se me descuadra el calendario, haber si me podeis echar una mano

Código PHP:
Ver original
  1. <?php
  2.   $monthNames = Array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
  3.     if (!isset($_REQUEST["month"])) $_REQUEST["month"] = date("n");
  4.     if (!isset($_REQUEST["year"]))  $_REQUEST["year"]  = date("Y");
  5.    
  6.   $cMonth = $_REQUEST["month"];
  7.   $cYear  = $_REQUEST["year"];
  8.                
  9.   $prev_year = $cYear;
  10.   $next_year = $cYear;
  11.  
  12.     $prev_month = $cMonth-1;
  13.     $next_month = $cMonth+1;
  14.  
  15.     if ($prev_month == 0 ) {
  16.     $prev_month = 12;
  17.     $prev_year = $cYear - 1;
  18.   }
  19.     if ($next_month == 13 ) {
  20.     $next_month = 1;
  21.     $next_year = $cYear + 1;
  22.   }
  23. ?>
  24.    <div id="calendar_div" name="calendar_div">
  25.     <table width="200">
  26.         <tr align="center">
  27.           <td bgcolor="#999999" style="color:#FFFFFF">
  28.                 <table width="100%" border="0" cellspacing="0" cellpadding="0">
  29.                     <tr>
  30.                       <td width="50%" align="left">&nbsp;&nbsp;<a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $prev_month . "&year=" . $prev_year; ?>" style="color:#FFFFFF">Previous</a></td>
  31.                       <td width="50%" align="right"><a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $next_month . "&year=" . $next_year; ?>" style="color:#FFFFFF">Next</a>&nbsp;&nbsp;</td>
  32.                     </tr>
  33.               </table>
  34.           </td>
  35.         </tr>
  36.         <tr>
  37.             <td align="center">
  38.               <table width="100%" border="0" cellpadding="2" cellspacing="2">
  39.                 <tr align="center">
  40.                   <td colspan="7" bgcolor="#999999" style="color:#FFFFFF"><strong><?php echo $monthNames[$cMonth-1].' '.$cYear; ?></strong></td>
  41.                 </tr>
  42.                 <tr>
  43.                   <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>L</strong></td>
  44.                   <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>M</strong></td>
  45.                   <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>X</strong></td>
  46.                   <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>J</strong></td>
  47.                   <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>V</strong></td>
  48.                   <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>S</strong></td>
  49.                   <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>D</strong></td>
  50.  
  51.                 </tr>
  52.  
  53.                 <?php
  54.                     $timestamp = mktime(0,0,0,$cMonth,1,$cYear);
  55.                     $maxday    = date("t",$timestamp);
  56.                     $thismonth = getdate ($timestamp);
  57.                     $startday  = $thismonth['wday'];
  58.  
  59.  
  60.                   for ($i=0; $i<($maxday+$startday); $i++) {
  61.                    if(($i % 7) == 0 ) echo "<tr>\n";
  62.                     if($i  < $startday) echo "<td></td>\n";
  63.  else echo "<td align='center' valign='middle' height='20px' >". ($i - $startday + 1) . "</td>\n";
  64.                    if(($i % 7) == 6 ) echo "</tr>\n";
  65.                   }  
  66.                  ?>
  67.               </table>
  68.             </td>
  69.         </tr>
  70.     </table>
  71. </div>

Etiquetas: calendario
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:56.