src/Slashworks/AppBundle/Command/ApiCommand.php
private function _parseCrontab($sDatetime, $sCrontab)
        {

            $aTime    = explode(' ', date('i G j n w', strtotime($sDatetime)));
            $sCrontab = explode(' ', $sCrontab);
            foreach ($sCrontab as $k => &$v) {
                $v = explode(',', $v);
                foreach ($v as &$v1) {
                    $v1 = preg_replace(array(
                                           '/^\*$/',
                                           '/^\d+$/',
                                           '/^(\d+)\-(\d+)$/',
                                           '/^\*\/(\d+)$/'
                                       ), array(
                                           'true',
                                           intval($aTime[$k]) . '===\0',
                                           '(\1<=' . intval($aTime[$k]) . ' and ' . intval($aTime[$k]) . '<=\2)',
                                           intval($aTime[$k]) . '%\1===0'
                                       ), $v1);
                }
                $v = '(' . implode(' or ', $v) . ')';
            }
            $sCrontab = implode(' and ', $sCrontab);

            return eval('return ' . $sCrontab . ';');
        }
private function _parseCrontab($sDatetime, $sCrontab)
        {

            $aTime    = explode(' ', date('i G j n w', strtotime($sDatetime)));
            $sCrontab = explode(' ', $sCrontab);
            foreach ($sCrontab as $k => &$v) {
                $v = explode(',', $v);
                foreach ($v as &$v1) {
                    $v1 = preg_replace(array(
                                           '/^\*$/',
                                           '/^\d+$/',
                                           '/^(\d+)\-(\d+)$/',
                                           '/^\*\/(\d+)$/'
                                       ), array(
                                           'true',
                                           intval($aTime[$k]) . '===\0',
                                           '(\1<=' . intval($aTime[$k]) . ' and ' . intval($aTime[$k]) . '<=\2)',
                                           intval($aTime[$k]) . '%\1===0'
                                       ), $v1);
                }
                $v = '(' . implode(' or ', $v) . ')';
            }
            $sCrontab = implode(' and ', $sCrontab);

            return eval('return ' . $sCrontab . ';');
        }
private function _parseCrontab ( $ sDatetime , $ sCrontab ) { $ aTime = explode ( ' ' , date ( 'i G j n w' , strtotime ( $ sDatetime ) ) ) ; $ sCrontab = explode ( ' ' , $ sCrontab ) ; foreach ( $ sCrontab as $ k => & $ v ) { $ v = explode ( ',' , $ v ) ; foreach ( $ v as & $ v1 ) { $ v1 = preg_replace ( array ( '/^\*$/' , '/^\d+$/' , '/^(\d+)\-(\d+)$/' , '/^\*\/(\d+)$/' ) , array ( 'true' , intval ( $ aTime [ $ k ] ) . '===\0' , '(\1<=' . intval ( $ aTime [ $ k ] ) . ' and ' . intval ( $ aTime [ $ k ] ) . '<=\2)' , intval ( $ aTime [ $ k ] ) . '%\1===0' ) , $ v1 ) ; } $ v = '(' . implode ( ' or ' , $ v ) . ')' ; } $ sCrontab = implode ( ' and ' , $ sCrontab ) ; return eval ( 'return ' . $ sCrontab . ';' ) ; }
Parse cron time string

@param $sDatetime
@param $sCrontab

@return mixed
Parse cron time string