SHARE
TWEET

Untitled

a guest Jan 14th, 2020 106 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <?php
  3. function bookingCalendar($month,$year){
  4.     $daystoWeek = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
  5.     $firstDay = mktime(0,0,0,$month,1,$year);
  6.     $numberOfDays = date('t', $firstDay);
  7.     $componDates = getdate($firstDay);
  8.     $varMonth = $componDates['month'];
  9.     $dayforWeek = $componDates['wday'];
  10.     $currentDate = date('Y-m-d');
  11.  
  12.     $calendar = "<table class='table table-bordered'>";
  13.     $calendar.= "<center><h2>$varMonth $year</h2>";
  14.  
  15.     $calendar = "<table class='table table-bordered'>";
  16.     $calendar .= "<center><h2>$varMonth $year</h2>";
  17.    
  18.     $calendar.="<a class='btn btn-xs btn-primary' href='?month=".date('m', mktime(0, 0, 0, $month-1, 1, $year))."&year=".date('Y', mktime(0, 0, 0, $month-1, 1, $year))."'>Previous Month</a>";
  19.    
  20.     $calendar.= "<a class='btn btn-xs btn-primary' href='?month=".date('m')."&year=".date('Y')."'>Current Month</a>";
  21.    
  22.     $calendar.= "<a class='btn btn-xs btn-primary' href='?month=".date('m', mktime(0, 0, 0, $month+1, 1, $year))."&year=".date('Y', mktime(0, 0, 0, $month+1, 1, $year))."'>Next Month</a></center><br>";
  23.    
  24.    
  25.        
  26.       $calendar .= "<tr>";
  27.  
  28.     foreach($daystoWeek as $day){
  29.         $calendar.="<th class='header'> $day </th>";
  30.     }
  31.     $calendar.= "</tr><tr>";
  32.  
  33.     if ($dayforWeek > 0 ) {
  34.         for ($i=0; $i <$dayforWeek ; $i++) {
  35.             $calendar.="<td></td>";
  36.         }
  37.     }
  38.     $currDay=1;
  39.     $month = str_pad($month,2, "0", STR_PAD_LEFT);
  40.     while ($currDay <= $numberOfDays) {
  41.  
  42.         if ($dayforWeek == 7) {
  43.             $dayforWeek = 0;
  44.             $calendar.="</tr><tr>";
  45.         }
  46.         $currDayRel = str_pad($month,2, "0", STR_PAD_LEFT);
  47.         $date = "$year-$month-$currDayRel";
  48.         $calendar.="<td><h4>$currDay</h4>";
  49.         $calendar.="</td>";
  50.  
  51.         $currDay++;
  52.         $dayforWeek++;
  53.  
  54.     }
  55.         if ($dayforWeek!=7) {
  56.             $remainDays = 7-$dayforWeek;
  57.             for ($i=0; $i < $remainDays; $i++) {
  58.                 $calendar.="<td></td>";
  59.             }
  60.         }
  61.     $calendar.="</tr>";
  62.     $calendar.="</table>";
  63.     echo $calendar;
  64.  
  65. }
  66. ?>
  67. <html>
  68. <head>
  69.     <title> </title>
  70.     <link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.min.css">
  71. </head>
  72. <body>
  73.     <div class="container">
  74.         <div class="row">
  75.             <div class="col-sm-12">
  76.                 <?php
  77.                     $componDates = getdate();
  78.                     $month = $componDates['mon'];
  79.                     $year = $componDates['year'];
  80.                     echo bookingCalendar($month,$year);
  81.                 ?>
  82.                
  83.             </div>
  84.            
  85.         </div>
  86.     </div>
  87.  
  88. </body>
  89. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top