Share Pastebin
Guest
Public paste!

dvil88

By: a guest | Jan 7th, 2010 | Syntax: PHP | Size: 0.76 KB | Hits: 6,354 | Expires: Never
Copy text to clipboard
  1. <?php
  2. //set this to select when the week starts
  3. // 0 = Monday
  4. // 1 = Sunday
  5. $day_start = 0;
  6.  
  7. //set this to your time zone
  8. date_default_timezone_set("Europe/Madrid");
  9.  
  10. $today = date("j");
  11. $first_day = date("w", mktime(0, 0, 0, date("n"), 1, date("Y")))+$day_start;
  12.  
  13. $total = date("t");
  14.                
  15. $j = $first_day;
  16.                
  17. printf(" %s :: %s\n",date("F"),date("Y"));//nombre_mes($mes));
  18.  
  19. //white spaces
  20. for ($x = 1 ; $x < $j ; $x++)
  21.         printf("   ");
  22.  
  23. //days of the month
  24. for ($i = 1 ; $i <= $total ; $i++) {
  25.         if($i == $today) {
  26.                 $color_day = ($today < 10) ? '  '.$i : ' '.$i;
  27.                 echo chr(27),'[','31m',$color_day,chr(27),'[','0m';
  28.         } else
  29.                 printf("%3d",$i);
  30.  
  31.         //end of the week
  32.         if ($j == 7){  
  33.                 $j = 0;
  34.                 printf("\n");
  35.         }
  36.         $j++;
  37. }
  38.        
  39. printf("\n");
  40. ?>