$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

Member Avatar for LastMitch

@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?

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.

Member Avatar for Zagga

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).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.