0
    $getTime = time();
    $newTimeFormat = date('h',$getTime);
if($newTimeFormat > 3 && $newTimeFormat <=12){

    echo "<section id=\"main\" class=\"column\"> 
         <iframe height=\"890\" width=\"100%\" frameborder=\"0\" id=\"display\" scrolling=\"auto\" src=\"displayDayShift.php\"></iframe>
    </section>";
    }
    if($newTimeFormat > 12 && $newTimeFormat <=21){

    echo "<section id=\"main\" class=\"column\">
         <iframe height=\"890\" width=\"100%\" frameborder=\"0\" id=\"display\" scrolling=\"auto\" src=\"displaySwingShift.php\"></iframe>
    </section>";
    }
    if($newTimeFormat > 21 && $newTimeFormat <=3){

    echo "<section id=\"main\" class=\"column\">
         <iframe height=\"890\" width=\"100%\" frameborder=\"0\" id=\"display\" scrolling=\"auto\" src=\"displayNightShift.php\"></iframe>
    </section>";
    }

The first if check works but once it gets to the 12th hour of the day it fails to display a page, any idea why this is happening? I have also tried an else if check

4
Contributors
3
Replies
4
Views
4 Years
Discussion Span
Last Post by Zagga
0

@kartikkp

The first if check works but once it gets to the 12th hour of the day it fails to display a page, any idea why this is happening? I have also tried an else if check

Is there a javascript related to this?

Is this gonna be on HTML5 website?

0

date('h', time()); returns the current hour in 12-hour format. The value will therefore always be between 1 and 12.

What you're probably looking for is date('H', time()); which returns the current hour in 24-hour format.

Further, your third check if($newTimeFormat > 21 && $newTimeFormat <= 3) will never return true. A number cannot be greater than 21 and less than or equal to 3.

Try if($newTimeFormat > 21 || $newTimeFormat <= 3) instead.

Edited by blocblue

0

Everything mentioned above plue you may need to change line 9 to if($newTimeFormat >= 12 && $newTimeFormat <=21){ if the split shift is between 12 and 9 (instead of 1 and 9 as it is currently).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.