jeudi 26 novembre 2015

Why does my IF statement doesn't catch the date in-between

I have many records in my database with different dates but my code doesn't catch the dates and it doesn't show up. What's the problem? Here is my code

            $year = date("Y");
            $sem1_s = date("M-d-Y", strtotime(date('Y') . '-8-1 00:00:00'));
            $sem1_e = date("M-d-Y", strtotime(date('Y') . '-12-31 00:00:00'));

            $sem2_s = date("M-d-Y", strtotime(date('Y') . '-01-1 00:00:00'));
            $sem2_e = date("M-d-Y", strtotime(date('Y') . '-06-30 00:00:00'));
            $date = '2015-10-15';

            $date2 = date("M-d-Y", strtotime(date('Y') . '-3-1 00:00:00'));

            if($date2 >= $sem1_s && $date2 <= $sem1_e){
                echo $date2;
                echo "First Sem";
            }
            else if($date2 >= $sem2_s && $date2 <= $sem2_e){
                 echo $date2;
                echo "Second Sem";
            }
            else{
                echo "error";


            }

Aucun commentaire:

Enregistrer un commentaire