Advertisement
rinaldohack

Untitled

Nov 20th, 2017
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.58 KB | None | 0 0
  1. <?php
  2. //php simple calendar, by rinaldo.id
  3. //created 11/20/2017
  4.  
  5. if (isset($_GET['month']))
  6.     $month = $_GET['month'];
  7. else
  8.     $month = date("m");
  9.  
  10. if (isset($_GET['year']))
  11.     $year = $_GET['year'];
  12. else
  13.     $year = date("Y");
  14.  
  15.  
  16. ?>
  17.  
  18. <table border="1">
  19. <tr>
  20.     <th>Sun</th>
  21.     <th>Mon</th>
  22.     <th>Tue</th>
  23.     <th>Wed</th>
  24.     <th>Thu</th>
  25.     <th>Fri</th>
  26.     <th>Sat</th>
  27. </tr>
  28.  
  29. <?php
  30. $lastmonth = $month - 1;
  31. if ($lastmonth == 0)
  32. {
  33.     $lastmonth=12;
  34.     $year2 = $year-1;
  35. }
  36. else
  37. {
  38.     $year2 = $year;
  39. }
  40.  
  41. $count_days_month = cal_days_in_month(CAL_GREGORIAN, $month, $year);
  42. $count_days_lastmonth = cal_days_in_month(CAL_GREGORIAN, $lastmonth, $year2);
  43.  
  44. $dayname = jddayofweek(gregoriantojd($month,1,$year),0);
  45. if ($dayname != 0)
  46. {
  47.     $startcal = $count_days_lastmonth - $dayname +1;
  48.  
  49. }
  50. else
  51. {
  52.     $startcal = 1;
  53. }
  54.  
  55. $counter = 0;
  56.  
  57. if ($startcal !=1)
  58. {
  59.     for ($loop = $startcal;  $loop <= $count_days_lastmonth; $loop++)
  60.     {  
  61.         $counter++;
  62.         if ($counter ==1)
  63.         {
  64.             echo "<tr>";
  65.         }
  66.         echo "<td><i>".$loop."</i></td>";
  67.         if ($counter %7 ==0)
  68.         {
  69.             echo "</tr>";
  70.             $counter =0;
  71.         }
  72.     }
  73. }
  74.     for ($loop = 1;  $loop <= $count_days_month; $loop++)
  75.     {
  76.         $counter++;
  77.         if ($counter ==1)
  78.         {
  79.             echo "<tr>";
  80.         }
  81.         echo "<td><b>".$loop."</b></td>";
  82.         if ($counter %7 ==0)
  83.         {
  84.             echo "</tr>";
  85.             $counter =0;
  86.         }
  87.     }
  88.     $nextmonth_date = 1;
  89.     if ($counter !=0)  
  90.     {      
  91.         for ($counter; $counter <7; $counter++)
  92.         {
  93.             echo "<td><i>".$nextmonth_date."</i></td>";
  94.             if ($nextmonth_date %7 ==0)
  95.             {
  96.                 echo "<hr>";
  97.             }      
  98.             $nextmonth_date++;
  99.  
  100.         }
  101.     }
  102.  
  103.  
  104. ?>
  105.  
  106. </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement