0
<table class="table row-border order-column">
  <thead>
     <tr>
        <th></th>
        <?php
              $days = cal_days_in_month(CAL_GREGORIAN, $month, $year);
              for($i=1;$i<=$days;$i++)
              {
        ?>
                 <th><?php echo $i; ?></th>
        <?php
              }
        ?>
     </tr>
  </thead>
  <tbody>
        <?php
           foreach ($student as $key => $value) 
           {
        ?>
              <tr>
                 <td class="cap"><?php echo $value->name; ?></td>
                 <?php
                    for($i=1;$i<=$days;$i++)
                       {  
                          $result = $this->db->select('*')->from('attendance')->where('studentID',$value->studentID)->where('day(date)', date($i))->where('month(date)', date($month))->where('Year(date)', date($year))->get()->row();
                          if(empty($result))
                          {
                             $date = date('Y-m-d');
                             $current_date = date('d',strtotime($date));
                             if($i < $current_date)
                             {
                    ?>
                                <td class="absent">A</td>
                    <?php
                             }
                             else
                             {
                    ?>
                                <td></td>
                    <?php             
                             }
                          }
                          else
                          {
                             $dateday = date('d',strtotime($result->date));
                             if($i == $dateday)
                             {
                    ?>
                                <td class="present">P</td>
                    <?php
                             }
                          }
                       }
                 ?>
              </tr>
        <?php
           }
        ?>
  </tbody>

In the above code I want to show absent while compare $current_date and $days but now what happen here only current month date show absent and previous month date show blank. Now, What am I going to do I don't want to show absent in future date. So, How can I do this? Please help me.

Thank You

Barton
  • 31
  • 3
  • It may solve your problem https://stackoverflow.com/questions/676824/how-to-calculate-the-difference-between-two-dates-using-php – Dhairya Lakhera Oct 09 '20 at 05:50
  • 2
    Does this answer your question? [How to calculate the difference between two dates using PHP?](https://stackoverflow.com/questions/676824/how-to-calculate-the-difference-between-two-dates-using-php) – Dhairya Lakhera Oct 09 '20 at 05:50

1 Answers1

0

Use Unix timestamp for your calculation and after that change Unix to gmt or utc time using ready functions to show.

Fernand
  • 50
  • 9