PHP code example of vojtechrichter / cron-expression-parser
1. Go to this page and download the library: Download vojtechrichter/cron-expression-parser library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
vojtechrichter / cron-expression-parser example snippets
declare(strict_types=1);
pe/Prague');
try {
$parser = \Vojtechrichter\CronExpressionParser\Parser::fromExpression('*/30 * * * * *');
echo 'Next run: ' . $parser->getNextRun()->format('j.m.Y H:i:s') . PHP_EOL;
} catch (\Exception $e) {
echo $e->getMessage();
}
declare(strict_types=1);
pe/Prague');
$validator = new \Vojtechrichter\CronExpressionParser\ExpressionSyntaxValidator();
// returns bool value
var_dump($validator->isValid('0 0 9 * jan-dec mon-fri'));
// throws an exception on error
$validator->validate('0 0 9 * jan-dec mon-fri');