-1
Well I’m trying to create a function that returns me true/false based on a certain time period. It buys the current server time and checks if it is within the reported period.
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 inform the beginning of 10:00 until 14:40 and the server is within this period, the function returns me true
.
The problem is when I use a period that turns the day, that is, the end time is less because it refers to the other day. Example: 18:00 until 8:00.
Does anyone know how I can verify this? I need to identify that the day has changed.
Could you perform day and time check? or does it need to be ONLY the time?
– sant0will
Yes, it has to be just the hour. I want to program the system to identify a company’s business hours and notify me of any access made to the system without being in the operating hours.
– Hugo Borges