Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- </head>
- <body>
- <?php
- /*
- asdfasdfa
- sdf
- asd
- fa
- sdf
- */
- //Son arrays para
- $meses_txt=array("","Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");
- $dias_txt=array("L","M","X","J","V","S","D");
- $hoy=getdate();
- $dia=!empty($_GET['dia'])?$_GET['dia']:$hoy['mday'];
- $mes=!empty($_GET['mes'])?$_GET['mes']:$hoy['mon'];
- $anio=!empty($_GET['anio'])?$_GET['anio']:$hoy['year'];
- if ($anio<=99) $anio+=2000;
- if (!checkdate($mes, $dia, $anio)||$anio<1971){
- echo "<HR><P CLASS='error'>ERROR: La fecha introducida no es válida...</P>";
- echo "<BR>< <A HREF='calendario.html'>volver</A> ><HR>";
- }
- else {
- //te da la el dia de la semana (1-7) (lunes,martes,miercoles,etc)
- $primer_dia=date("N",mktime(0,0,0,$mes,1,$anio));
- $ultimo_dia=date("t",mktime(0,0,0,$mes,1,$anio));
- echo "$dia / $mes / $anio";
- }
- ?>
- <table border="1" cellpadding="7">
- <tr>
- <td align="center" colspan="7"> <?php echo "$meses_txt[$mes] , $anio"; ?></td>
- </tr>
- <tr>
- <?php
- for ($i=0; $i<7; $i++){
- echo "<td align='right'> $dias_txt[$i] </td>";
- }
- ?>
- </tr>
- <?php
- //bucle de los dias del mes
- $contador_de_dias=1;
- $numhuecos=$primer_dia-1;
- while ($contador_de_dias<=$ultimo_dia) {
- echo "<tr>";
- //si el primer dia del mes no es lunes
- if ($primer_dia>1 && $contador_de_dias==1) {
- echo "<td colspan=".$numhuecos."></td>";
- for($i=$numhuecos; $i<7; $i++){
- echo "<td>$contador_de_dias</td>";
- $contador_de_dias ++;
- }
- } else{
- for ($i=0;$i<7 && $contador_de_dias<=$ultimo_dia;$i++){
- echo "<td>$contador_de_dias</td>";
- $contador_de_dias++;
- }
- }
- echo "</tr>";
- }
- ?>
- </table>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement