R
R
rusgayfer2018-02-02 16:57:16
PHP
rusgayfer, 2018-02-02 16:57:16

How to make scheduled execution (interval)?

It is necessary to implement such a scheme. I have a script, I do the execution of the script there according to the schedule. That is, specifying the time, for example, from 10:00 to 23:00 (the script will work). And from 23:00 to 10:00 will not work. How to do this correctly, without krone? I have a script on my cron that runs every 5 minutes.
Users at me choose when the script will work. Any time can be specified.
Here is an example of how I do it:

$date = date("H:s");
$idat = date('00:40');

if(isset($date) && $date >= $idat) { $pub = 'Работает скрипт'; } else { $pub = 'Не работает скрипт'; }
echo $pub;

But this is not the correct implementation, here it compares not time, but by numbers

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rusgayfer, 2018-02-02
@rusgayfer

Found a solution, but the author has already removed it. In short, this is more correct

$start_time = "07:30"; // Начинать
$end_time = "13:15"; // Заканчивать

if ((date('H:i') > $start_time) && (date('H:i') < $end_time)) {
    echo 'Работает';
} else { echo 'Не работает'; }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question