jeudi 21 septembre 2017

If statement not working with between dates

I have the following if statement:

 $current=date('d/m/Y');
 $next_year=date('y')+1;

 $q1a='01/04/'.date('Y');
 $q1b='30/06/'.date('Y');

 $q2a='01/07/'.date('Y');
 $q2b='30/09/'.date('Y');

 $q3a='01/09/'.date('Y');
 $q3b='31/12/'.date('Y');

 $q4a='01/01/20'.$next_year;
 $q4b='31/03/20'.$next_year;

       if (($current > $q1a) && ($current < $q1b)) { $currentquarter='Q1'; 
 } elseif (($current > $q2a) && ($current < $q2b)) { $currentquarter='Q2'; 
 } elseif (($current > $q3a) && ($current < $q3b)) { $currentquarter='Q3'; 
 } elseif (($current > $q4a) && ($current < $q4b)) { $currentquarter='Q4';
 }  

echo $currentquarter;

BUT its returning Q1 even though it should be Q3 as todays date falls between 01/09/2017 and 31/12/2017

Aucun commentaire:

Enregistrer un commentaire