Well I'm trying to create a function that returns me true / false based on a certain time period. It buys the server's current time and checks to see if it is within the specified time.
Example:
function Verifica_Expediente ($inicio, $fim) {
// Coleta dados
$hora1 = strtotime(date('Y-m-d' . $inicio));
$hora2 = strtotime(date('Y-m-d' . $fim));
$agora = time();
// Verifica horas
if ($hora1 <= $agora && $agora <= $hora2) {
return true;
} else {
return false;
}
}
Verifica_Expediente ("10:00:00", "14:30:00");
When I report the start from 10:00 AM until 2:40 PM and the server is within that period, the function returns me true
.
The problem is when I use a period that turns the day, ie the end time is less because it is referring to the other day. Example: 6:00 p.m. to 8:00 p.m.
Does anyone know how I can verify this? I need to identify that the day has changed.