title: Compare dates between seasons into following year
body: <p>I have 3 seasons (this is how the client charges), <BR>
  season 1 starts 1st April &amp; ends 31st July (2021-04-01 to 2021-07-31)<BR>
  season 2 starts 1st August &amp; ends 30th November (2021-08-01 to 2021-11-30)<BR>
  season 3 starts 1st December &amp; ends 31st March (2021-12-01 to 2022-03-31<BR>
  Season 3 spans from one year into the next year(Dec to Mar)<BR></p>
  <p>The dates are from DB in this format <strong>2021-11-03</strong>. I replace the seasons year with the booking_start &amp; booking_end year with $BSyear &amp; $BEyear.<BR></p>
  <p><strong>Below I have code for the seasons plus one year for other calculations as I only need to go one year into the future.</strong><BR></p>
  <p>My issue is I can get season 1 &amp; season 2 to work but I'm having an issue with season 3. I think it may be because it crosses from one year to the next but I can't get my head around what's causing the issue. <BR></p>
  <p>Are my &gt;= calculations done correctly or are they conflicting with each other? Season 3 calculation is at the very bottom.</p>
  <pre><code>    $BS =&quot;2021-06-02&quot;;//booking start date will become a POSTED FORM VARIABLE HERE
      list($BSyear, $BSmonth, $BSday) = explode(&quot;-&quot;, $BS);
      $booking_start = $BSyear.'-'.$BSmonth.'-'.$BSday;
      $booking_start = strtotime($booking_start);
  
      
          //BOOKING END
      $BE =&quot;2021-06-04&quot;;//booking end date will become a POSTED FORM VARIABLE HERE
      list($BEyear, $BEmonth, $BEday) = explode(&quot;-&quot;, $BE);
      $booking_end = $BEyear.'-'.$BEmonth.'-'.$BEday;
      $booking_end = strtotime($booking_end);
      
      
      //...........START: Row 1 Season 1 Dates...........\\
      
      $id = 1;
      
      $sql = &quot;SELECT * FROM season_switch WHERE id = ?&quot;;
      $stmt = $conn-&gt;prepare($sql); 
      $stmt-&gt;bind_param(&quot;i&quot;, $id);
      $stmt-&gt;execute();
      $result = $stmt-&gt;get_result();
  
  
      if ($result-&gt;num_rows &gt; 0) {    
  
  
      //output data of row
      while($row = $result-&gt;fetch_assoc()) {
          
          $SS1 .= $row[&quot;start_date&quot;];//SS1 stands for season 1 start
          $SE1 .= $row[&quot;end_date&quot;];//SE1 stands for season 1 end
          
          $SS1 = date(&quot;Y-m-d&quot;, strtotime($SS1));
          $SE1 = date(&quot;Y-m-d&quot;, strtotime($SE1));
          
          //Season start
      list($SS1year, $SS1month, $SS1day) = explode(&quot;-&quot;, $SS1);
      $season_start = $BSyear.'-'.$SS1month.'-'.$SS1day;//Season 1 start year gets booking end year value here with $BSyear
      $season_start = strtotime($season_start);
      
      
          //Season end
      list($SE1year, $SE1month, $SE1day) = explode(&quot;-&quot;, $SE1);
      $season_end = $BEyear.'-'.$SE1month.'-'.$SE1day;//Season 1 end year gets booking end year value here with $BEyear
      $season_end = strtotime($season_end);
      
      }
      }
      else{
      echo &quot;0 results available for season 1&quot;.'&lt;BR&gt;';
      }
      //...........END: Row 1 Season 1 Dates...........\\
          
      //...........START: Row 2 Season 2 Dates...........\\
      
      $id = 2;
      
      $sql = &quot;SELECT * FROM season_switch WHERE id = ?&quot;;
      $stmt = $conn-&gt;prepare($sql); 
      $stmt-&gt;bind_param(&quot;i&quot;, $id);
      $stmt-&gt;execute();
      $result = $stmt-&gt;get_result();
  
      if ($result-&gt;num_rows &gt; 0) {    
  
  
      //output data of row
      while($row = $result-&gt;fetch_assoc()) {
          
          $SS2 .= $row[&quot;start_date&quot;];//SS2 stands for season 2 start
          $SE2 .= $row[&quot;end_date&quot;];//SE2 stands for season 2 end
          
          $SS2 = date(&quot;Y-m-d&quot;, strtotime($SS2));
          $SE2 = date(&quot;Y-m-d&quot;, strtotime($SE2));
          
          //Season 2 start
      list($SS2year, $SS2month, $SS2day) = explode(&quot;-&quot;, $SS2);
      $season2_start = $BSyear.'-'.$SS2month.'-'.$SS2day;//Season 2 start year gets booking end year value here with $BSyear
      $season2_start = strtotime($season2_start);
      
          //Season 2 end
      list($SE2year, $SE2month, $SE2day) = explode(&quot;-&quot;, $SE2);
      $season2_end = $BEyear.'-'.$SE2month.'-'.$SE2day;//Season 2 end year gets booking end year value here with $BEyear
      $season2_end = strtotime($season2_end);
      
      }
      }
      else{
      echo &quot;0 results available for season 2&quot;.'&lt;BR&gt;';
      }
      //...........END: Row 2 Season 2 Dates...........\\
      
      //...........START: Row 3 Season 3 Dates...........\\
  
      
      $id = 3;
      
      $sql = &quot;SELECT * FROM season_switch WHERE id = ?&quot;;
      $stmt = $conn-&gt;prepare($sql); 
      $stmt-&gt;bind_param(&quot;i&quot;, $id);
      $stmt-&gt;execute();
      $result = $stmt-&gt;get_result();
  
  
      if ($result-&gt;num_rows &gt; 0) {    
  
  
      //output data of row
      while($row = $result-&gt;fetch_assoc()) {
          
          $SS3 .= $row[&quot;start_date&quot;];//SS3 stands for season 3 start
          $SE3 .= $row[&quot;end_date&quot;];//SE3 stands for season 3 end
          
          $SS3 = date(&quot;Y-m-d&quot;, strtotime($SS3));
          $SE3 = date(&quot;Y-m-d&quot;, strtotime($SE3));
          
          
          //Season 3 start    
      list($SS3year, $SS3month, $SS3day) = explode(&quot;-&quot;, $SS3);
      $season3_start = $BSyear.'-'.$SS3month.'-'.$SS3day;//Season 3 start year gets booking end year value here with $BSyear
      $season3_start = strtotime($season3_start);
      
          //Season 3 end
      list($SE3year, $SE3month, $SE3day) = explode(&quot;-&quot;, $SE3);
      $season3_end = $BEyear.'-'.$SE3month.'-'.$SE3day;//Season 3 end year gets booking end year value here with $BEyear
      $season3_end = strtotime($season3_end);
      
      }
      }
      else{
      echo &quot;0 results available for season 3&quot;.'&lt;BR&gt;';
      }
      //...........END: Row 3 Season 3 Dates...........\\
  
      
      //For when season 1 goes into next year
      $season_start_plus_1_year = strtotime('+ 1 year', $season_start);
      $season_end_plus_1_year = strtotime('+ 1 year', $season_end);
      
      //-------------------
      
      //For when season 2 goes into next year
      $season2_start_plus_1_year = strtotime('+ 1 year', $season2_start);
      $season2_end_plus_1_year = strtotime('+ 1 year', $season2_end);
      
      //-------------------
  
      
      //For when season 3 goes into next year
      $season3_start_plus_1_year = strtotime('+ 1 year', $season3_start);
      $season3_end_plus_1_year = strtotime('+ 1 year', $season3_end);
      //-------------------
  
  
  
  //-------------START: COMPLEATLY IN SEASON 1 or 2 or 3 ---------------// 
  
          //compleatly season 1
          if($booking_start &gt;= $season_start and $booking_start &lt;= $season_end and $booking_end &gt; $season_start and $booking_end &lt;= $season_end) {
              
              $low_mid_peak_switch = 1;
              $datediff = $booking_end - $booking_start;
              echo '&lt;span style=&quot;color:red;&quot;&gt;'.'Booking is compleatly in SEASON 1'.'&lt;/span&gt;';
              echo '&lt;BR&gt;';
              echo $datediff ='&lt;span style=&quot;color:limegreen;&quot;&gt;'.round($datediff / (60 * 60 * 24)).' days @ Season 1 price $'.'&lt;/span&gt;';
              echo '&lt;BR&gt;';
              exit;
          
      }
      
      
          //compleatly season 2   
          if($booking_start &gt;= $season2_start and $booking_start &lt;= $season2_end and $booking_end &gt; $season2_start and $booking_end &lt;= $season2_end) {
              
              $low_mid_peak_switch = 2;
              echo '&lt;span style=&quot;color:red;&quot;&gt;'.'Booking is compleatly in SEASON 2'.'&lt;/span&gt;';
              echo '&lt;BR&gt;';
              $datediff = $booking_end - $booking_start;
              echo '&lt;span style=&quot;color:OliveDrab;&quot;&gt;'.round($datediff / (60 * 60 * 24)).' days @ Season 2 price $'.'&lt;/span&gt;';
              echo '&lt;BR&gt;';
              exit;
          
      }
      
          //compleatly season 3
          if($booking_start &gt;= $season3_start &amp;&amp; $booking_end &lt;= $season3_end) {
              
              $low_mid_peak_switch = 3;
              echo '&lt;span style=&quot;color:red;&quot;&gt;'.'Booking is compleatly in SEASON 3'.'&lt;/span&gt;';
              echo '&lt;BR&gt;';
              $datediff = $booking_end - $booking_start;
              echo '&lt;span style=&quot;color:LightSeaGreen;&quot;&gt;'.round($datediff / (60 * 60 * 24)).' days @ Season 3 price $'.'&lt;/span&gt;';
              echo '&lt;BR&gt;';
              exit;
      }
      
  //-------------END: COMPLEATLY IN SEASON 1 or 2 or 3 ---------------//
  </code></pre>