Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //php simple calendar, by rinaldo.id
- //created 11/20/2017
- if (isset($_GET['month']))
- $month = $_GET['month'];
- else
- $month = date("m");
- if (isset($_GET['year']))
- $year = $_GET['year'];
- else
- $year = date("Y");
- ?>
- <table border="1">
- <tr>
- <th>Sun</th>
- <th>Mon</th>
- <th>Tue</th>
- <th>Wed</th>
- <th>Thu</th>
- <th>Fri</th>
- <th>Sat</th>
- </tr>
- <?php
- $lastmonth = $month - 1;
- if ($lastmonth == 0)
- {
- $lastmonth=12;
- $year2 = $year-1;
- }
- else
- {
- $year2 = $year;
- }
- $count_days_month = cal_days_in_month(CAL_GREGORIAN, $month, $year);
- $count_days_lastmonth = cal_days_in_month(CAL_GREGORIAN, $lastmonth, $year2);
- $dayname = jddayofweek(gregoriantojd($month,1,$year),0);
- if ($dayname != 0)
- {
- $startcal = $count_days_lastmonth - $dayname +1;
- }
- else
- {
- $startcal = 1;
- }
- $counter = 0;
- if ($startcal !=1)
- {
- for ($loop = $startcal; $loop <= $count_days_lastmonth; $loop++)
- {
- $counter++;
- if ($counter ==1)
- {
- echo "<tr>";
- }
- echo "<td><i>".$loop."</i></td>";
- if ($counter %7 ==0)
- {
- echo "</tr>";
- $counter =0;
- }
- }
- }
- for ($loop = 1; $loop <= $count_days_month; $loop++)
- {
- $counter++;
- if ($counter ==1)
- {
- echo "<tr>";
- }
- echo "<td><b>".$loop."</b></td>";
- if ($counter %7 ==0)
- {
- echo "</tr>";
- $counter =0;
- }
- }
- $nextmonth_date = 1;
- if ($counter !=0)
- {
- for ($counter; $counter <7; $counter++)
- {
- echo "<td><i>".$nextmonth_date."</i></td>";
- if ($nextmonth_date %7 ==0)
- {
- echo "<hr>";
- }
- $nextmonth_date++;
- }
- }
- ?>
- </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement