public static function matchTime($time, $expr)
    {
        //ArgValidator::assert($time, array('string', 'numeric'));
        //ArgValidator::assert($expr, 'string');

        $cronExpr = preg_split('/\s+/', $expr, null, PREG_SPLIT_NO_EMPTY);
        if (count($cronExpr) !== 5) {
            throw new Exception\InvalidArgumentException(sprintf(
                    'cron expression should have exactly 5 arguments, "%s" given',
                    $expr
            ));
        }

        if (is_string($time)) $time = strtotime($time);

        $date = getdate($time);

        return self::matchTimeComponent($cronExpr[0], $date['minutes'])
        && self::matchTimeComponent($cronExpr[1], $date['hours'])
        && self::matchTimeComponent($cronExpr[2], $date['mday'])
        && self::matchTimeComponent($cronExpr[3], $date['mon'])
        && self::matchTimeComponent($cronExpr[4], $date['wday']);
    }
public static function matchTime($time, $expr)
    {
        //ArgValidator::assert($time, array('string', 'numeric'));
        //ArgValidator::assert($expr, 'string');

        $cronExpr = preg_split('/\s+/', $expr, null, PREG_SPLIT_NO_EMPTY);
        if (count($cronExpr) !== 5) {
            throw new Exception\InvalidArgumentException(sprintf(
                    'cron expression should have exactly 5 arguments, "%s" given',
                    $expr
            ));
        }

        if (is_string($time)) $time = strtotime($time);

        $date = getdate($time);

        return self::matchTimeComponent($cronExpr[0], $date['minutes'])
        && self::matchTimeComponent($cronExpr[1], $date['hours'])
        && self::matchTimeComponent($cronExpr[2], $date['mday'])
        && self::matchTimeComponent($cronExpr[3], $date['mon'])
        && self::matchTimeComponent($cronExpr[4], $date['wday']);
    }
public static function matchTime ( $ time , $ expr ) { //ArgValidator::assert($time, array('string', 'numeric')); //ArgValidator::assert($expr, 'string'); $ cronExpr = preg_split ( '/\s+/' , $ expr , null , PREG_SPLIT_NO_EMPTY ) ; if ( count ( $ cronExpr ) !== 5 ) { throw new Exception \ InvalidArgumentException ( sprintf ( 'cron expression should have exactly 5 arguments, "%s" given' , $ expr ) ) ; } if ( is_string ( $ time ) ) $ time = strtotime ( $ time ) ; $ date = getdate ( $ time ) ; return self :: matchTimeComponent ( $ cronExpr [ 0 ] , $ date [ 'minutes' ] ) && self :: matchTimeComponent ( $ cronExpr [ 1 ] , $ date [ 'hours' ] ) && self :: matchTimeComponent ( $ cronExpr [ 2 ] , $ date [ 'mday' ] ) && self :: matchTimeComponent ( $ cronExpr [ 3 ] , $ date [ 'mon' ] ) && self :: matchTimeComponent ( $ cronExpr [ 4 ] , $ date [ 'wday' ] ) ; }
determine whether a given time falls within the given cron expr

@param string|numeric $time
timestamp or strtotime()-compatible string
@param string $expr
any valid cron expression, in addition supporting:
range: '0-5'
range + interval: '10-59/5'
comma-separated combinations of these: '1,4,7,10-20'
English months: 'january'
English months (abbreviated to three letters): 'jan'
English weekdays: 'monday'
English weekdays (abbreviated to three letters): 'mon'
These text counterparts can be used in all places where their
numerical counterparts are allowed, e.g. 'jan-jun/2'
A full example:
'0-5,10-59/5 * 2-10,15-25 january-june/2 mon-fri' -
every minute between minute 0-5 + every 5th min between 10-59
every hour
every day between day 2-10 and day 15-25
every 2nd month between January-June
Monday-Friday
@throws Exception\InvalidArgumentException on invalid cron expression
@return bool
determine whether a given time falls within the given cron expr