Friends, I have a problem with my program. It turns out that in my database (mysql) I indicate the days and hours in which an entered task will be executed. And through a php process I'm running the processes that meet that condition and there's the problem.
Currently, if I have a task will be executed from Monday to Friday, from 08:30 to 19:00 hrs when comparing the hours the condition fails me.
$horainicio= "08:30";
$horafin = "19:00";
//OBTENER FECHA Y HORA
$time = strftime( "%Y-%m-%d %H:%M:%S", time() ); //FECHA y HORA
$hora = strftime("%H:%M", time() ); //HORA
if(($horaini <= $hora) and ($hora <= $horaterm)) {
echo "El proceso correra \n";
} else {
echo "El proceso no correra \n";
}
However, the problem arises when it is after 12 o'clock at night, since 08:30 is longer than the Current Time, which would be 05:00, 01:00, etc. Then try to solve it by converting the time to timestamp but, the case is the same, since my process must take the current date and when consulting the database every day, you must insert the current date at the time (08:30) which would be the same date that the current system has, therefore it will continue to be larger. = /
Does anyone have any idea how to solve it?