Condition with 4 values

Asked

Viewed 23 times

1

Oops, good morning, good morning!

The thing is, I need to know how I make the following comparison: I have two values, dial in and out, if the time is marked, the user does not select time that are in the meantime...

if(($hora_in > $hora_marcada_in && $hora_out < $hora_marcada_out)){
  echo 'PODE MARCAR';
  }else{
  echo 'NÃO PODE MARCAR';
}

To better understand, if there is an appointment from 14h00 to 16h00 the user will not be able to mark values that are in the middle of these two times... ex: 15:00 to 17:00 or 15:00 to 15:30... I’m losing my mind...

Thank you so much!

  • 1

    The problem with your attempt is that you compared input to input and output to output, so you have to compare it like this saida_pretendida <= entrada_existente || entrada_pretendida >= saida_existente . More details on yellow box link

  • My friend! Thank you very much! I was not knowing how to look, sorry for the duplicity of the issue!

  • 1

    I improved the title of that, I was very bad to think. But when you doubt about the content, let us know that we try to solve. Normally you will take the scheduled time and take the test I mentioned in each of the existing schedules in a loop that goes through all the schedules of the day. If scheduling is possible during the turn of the day, you need to make the comparison with the full timestamp.

  • Thanks again, I kind of understood the logic, it makes kind of a check "backwards"... But I’ve applied and solved! Thank you very much!

  • 1

    It is a situation that appears to have many conditions, but it is simple, or its time is before or is after the existing :D qq another condition is occupied. To be earlier, it has to end before the beginning of the next one. To be later, it has to start after the end of the previous one.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.