Posted By

spcmnk7 on 05/04/11


Tagged

php calendar


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

manteca


Calendar


 / Published in: PHP
 

URL: http://www.phpjabbers.com/how-to-make-a-php-calendar-php26-4.html

php calendar with an italian localization, starts on Monday

  1. <?php
  2. $monthNames = array("Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre");
  3.  
  4. $month = date('n');
  5. $year = date('Y');
  6. ?>
  7.  
  8. $cMonth = ($month - 2) + $k;
  9.  
  10. $timestamp = mktime(0,0,0,$cMonth, 1, $year);
  11. $maxday = date('t', $timestamp);
  12. $thisMonth = getdate($timestamp);
  13. $startday = ($thisMonth['wday'] + 6) % 7 ; ?>
  14.  
  15.  
  16.  
  17. <table class="calendar" id="calendar-<?php echo $k?>" cellspacing="0" cellpadding="0" summary="Calendario degli eventi">
  18. <caption><a href="#" title="mese precedente" class="calendar-nav prev">&laquo;</a> <?php echo $monthNames[$month-1]?> <a class="calendar-nav next" href="#" title="mese successivo">&raquo;</a></caption>
  19. <tr>
  20. <th scope="col" abbr="Luned&igrave;" title="Luned&igrave;">L</th>
  21. <th scope="col" abbr="Marted&igrave;" title="Marted&igrave;">M</th>
  22. <th scope="col" abbr="Mercoled&igrave;" title="Mercoled&igrave;">M</th>
  23. <th scope="col" abbr="Gioved&igrave;" title="Gioved&igrave;">G</th>
  24. <th scope="col" abbr="Venerd&igrave;" title="Venerd&igrave;">V</th>
  25. <th scope="col" abbr="Sabato" title="Sabato">S</th>
  26. <th scope="col" abbr="Domenica" title="Domenica">D</th>
  27. </tr>
  28.  
  29. <?php
  30. for ($i=0; $i<($maxday + $startday); $i++) {
  31. if(($i % 7) == 0)
  32. echo "<tr>\n";
  33.  
  34. if(($i < $startday))
  35. echo "<td>&nbsp;</td>\n";
  36. else
  37. echo "<td>" . ($i - $startday + 1) . "</td>\n";
  38.  
  39. if (($i % 7) == 6)
  40. echo "</tr>\n";
  41. }
  42.  
  43. ?>
  44.  
  45. </table>

Report this snippet  

You need to login to post a comment.