Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title></title>
  5. </head>
  6. <body>
  7.  
  8.  
  9. <?php
  10. /*
  11. asdfasdfa
  12. sdf
  13. asd
  14. fa
  15. sdf
  16.  
  17. */
  18.  
  19. //Son arrays para
  20. $meses_txt=array("","Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");
  21. $dias_txt=array("L","M","X","J","V","S","D");
  22.  
  23. $hoy=getdate();
  24. $dia=!empty($_GET['dia'])?$_GET['dia']:$hoy['mday'];
  25. $mes=!empty($_GET['mes'])?$_GET['mes']:$hoy['mon'];
  26. $anio=!empty($_GET['anio'])?$_GET['anio']:$hoy['year'];
  27. if ($anio<=99) $anio+=2000;
  28. if (!checkdate($mes, $dia, $anio)||$anio<1971){
  29. echo "<HR><P CLASS='error'>ERROR: La fecha introducida no es válida...</P>";
  30. echo "<BR>< <A HREF='calendario.html'>volver</A> ><HR>";
  31. }
  32.  
  33. else {
  34. //te da la el dia de la semana (1-7) (lunes,martes,miercoles,etc)
  35. $primer_dia=date("N",mktime(0,0,0,$mes,1,$anio));
  36.  
  37. $ultimo_dia=date("t",mktime(0,0,0,$mes,1,$anio));
  38.  
  39. echo "$dia / $mes / $anio";
  40.  
  41. }
  42.  
  43.  
  44. ?>
  45.  
  46. <table border="1" cellpadding="7">
  47. <tr>
  48. <td align="center" colspan="7"> <?php echo "$meses_txt[$mes] , $anio"; ?></td>
  49.  
  50. </tr>
  51.  
  52. <tr>
  53.  
  54. <?php
  55.  
  56. for ($i=0; $i<7; $i++){
  57. echo "<td align='right'> $dias_txt[$i] </td>";
  58. }
  59. ?>
  60.  
  61. </tr>
  62.  
  63.  
  64. <?php
  65. //bucle de los dias del mes
  66. $contador_de_dias=1;
  67. $numhuecos=$primer_dia-1;
  68. while ($contador_de_dias<=$ultimo_dia) {
  69.  
  70. echo "<tr>";
  71. //si el primer dia del mes no es lunes
  72. if ($primer_dia>1 && $contador_de_dias==1) {
  73. echo "<td colspan=".$numhuecos."></td>";
  74. for($i=$numhuecos; $i<7; $i++){
  75. echo "<td>$contador_de_dias</td>";
  76. $contador_de_dias ++;
  77. }
  78.  
  79. } else{
  80.  
  81. for ($i=0;$i<7 && $contador_de_dias<=$ultimo_dia;$i++){
  82.  
  83. echo "<td>$contador_de_dias</td>";
  84. $contador_de_dias++;
  85.  
  86. }
  87. }
  88.  
  89. echo "</tr>";
  90.  
  91.  
  92. }
  93.  
  94.  
  95. ?>
  96.  
  97.  
  98. </table>
  99.  
  100.  
  101. </body>
  102. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement