Jump to content

[SOLVED] if statements cant both be true


jaxdevil

Recommended Posts

Below is my code. based on my servers time (which appears to be off by like 20 minutes) I set the following to say 'work time' when it is between 8:30AM and 5:00PM, and say 'not work time' when it is not those times. Any idea why it is displaying "work timenot work time" (both if statements)?

 

<?
if (date("Hi")>0410 and date("Hi")<1240);
{
    ?>work time<?
}    
?>
<?
if (date("Hi")>1239 and date("Hi")<2400
or (date("Hi")>0000 and date("Hi")<0411));
{
    ?>not work time<?
}    
?>

Link to comment
https://forums.phpfreaks.com/topic/102198-solved-if-statements-cant-both-be-true/
Share on other sites

Why check both

<?php
if (date("Hi")>0410 and date("Hi")<1240);
{
echo "Work Time";
} else {
echo "not work time";
}
?>

 

Unless you are going to check other times of the day for other things, it's either work time or not.

 

Ray

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.