dimanche 21 juin 2015

If time is between two hours PHP

I looked through all the relevant posts but I can't find where I am going wrong. My goal is to have a picture display if the time is between 6am to 7pm and then have a different one if the time falls between 7pm and 6am. This is what I have and I am just getting confused now.

date_default_timezone_set('Canada/Newfoundland'); // NDT
$current_date = date('G:i:s');

if ($current_date >= 19 && $current_date <= 6) {
     echo "<img src=' $night ' />";
} else {
     echo "<img src=' $day ' />";
}

Whenever I run what I have it is ALWAYS the else that shows up so I believe that the issue is with how I am setting up the time? Thanks in advance for any help given.

Aucun commentaire:

Enregistrer un commentaire