如何确定cron执行日期直到某个日期?

I want to determine the dates with the hours when Crons (of a Crontab) are going to run.

Is there a solution to recover all the dates of execution of a cron? For example, the variable crontab is "15 7 * * *" and the end date is "2018-08-05", i would like to find these dates :

  • 2018-08-01 07:15:00 UTC
  • 2018-08-02 07:15:00 UTC
  • 2018-08-03 07:15:00 UTC
  • 2018-08-04 07:15:00 UTC
  • 2018-08-05 07:15:00 UTC

All my scripts are in PHP. If there is a solution in php it would be better.. Or an API ? Thanks for purpose...

If you just need to count and see all the dates from "now" to "limit date", you can use this code:

$date = new DateTime("now");
$endDate = new DateTime("2018-08-05 07:15:00");
$count = 0;

while ($date <= $endDate ) {
    $count++;
    $date->modify("+1day");
    echo $date->format("Y-m-d 07:15:00"), "
";
}
echo "There is $count dates";

But if you need just start cron in need time - use two cron records:

15 7 * 1-7 * user   command #start year to July
15 7 1-5 8 * user   command #August 1 - 5

https://www.codediesel.com/php/cron-expression-parser-in-php/

Here the solution. Perfect for all Cron !