How To Compare six time on PHP? -


i have problem compare 3 time on php.

so user input time now(). must have compare 3 different time have been load database.

the code this

    if(isset($_post[submit])) {           $waktu = strtotime($_post[waktu]); //$waktu variabel input set  hh:mm       /*get time setting mysql*/       $sql4 = "select * promo_time";      $hasil4 = mysqli_query($sql4);      $data4 = mysqli_fetch_assoc($hasil4);        $jam1_a = strtotime($data4[waktu_promo1_a]);      $jam1_b = strtotime($data4[waktu_promo1_b]);       $jam2_a = strtotime($data4[waktu_promo2_a]);      $jam2_b = strtotime($data4[waktu_promo2_b]);       $jam3_a = strtotime($data4[waktu_promo3_a]);      $jam3_b = strtotime($data4[waktu_promo3_b]);  if(($waktu >= $jam3_a) || ($waktu <= $jam3_b)){            if(($waktu >= $jam2_a) || ($waktu <= $jam2_b)) {                 if(($waktu >= $jam1_a) || ($waktu <= $jam1_b)) {                     echo "success";                  }                else {                     echo "erro 3";                     }             }           else {              echo "error 2";             }        }//endif      else {           echo "error 1";            }         } 

the code result show "succes" if use or operator. if user , operator code result error 1.

the preview enter image description here

if input 16:00 result success, if input 19:00 still success.

can me fix issue?

thanks in advance

a >= 1 || <= 2 true numeric a. use &&

like this:

$in1 = $waktu >= $jam1_a && $waktu <= $jam1_b;   $in2 = $waktu >= $jam2_a && $waktu <= $jam2_b; $in3 = $waktu >= $jam3_a && $waktu <= $jam3_b; $result = ($in1 || $in2 || $in3) ? 'success' : 'error'; echo $result; 

Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -