public static function isDue($pattern, \DateTime $time = null)
  {
    if($time === null)
    {
      $time = new \DateTime();
    }
    // trim time back to last round minute
    $time->setTime($time->format('H'), $time->format('i'));

    $expression = Expression::createFromPattern($pattern);

    foreach(self::$_formats as $pos => $fmt)
    {
      if($pos > 4 && !isset($expression[$pos]))
      {
        continue;
      }

      $cmp = intval($time->format($fmt));

      $posSuccess = false;
      foreach($expression[$pos] as $part)
      {
        if($part['full'] == '*' || $part['full'] == $cmp || $posSuccess)
        {
          $posSuccess = true;
          break;
        }

        // process order: range, modulus

        // doesn't match val
        if(isset($part['val']) && $part['val'] != '*' && $cmp != $part['val'])
        {
          continue;
        }

        // out of range
        if(isset($part['min']) && isset($part['max']) && ($cmp < $part['min'] || $cmp > $part['max']))
        {
          continue;
        }

        $offset = isset($part['min']) ? $part['min'] : 0;
        if(isset($part['mod']) && (($cmp - $offset) % $part['mod']) != 0)
        {
          continue;
        }

        $posSuccess = true;
      }
      if(!$posSuccess)
      {
        return false;
      }
    }
    return true;
  }
public static function isDue($pattern, \DateTime $time = null)
  {
    if($time === null)
    {
      $time = new \DateTime();
    }
    // trim time back to last round minute
    $time->setTime($time->format('H'), $time->format('i'));

    $expression = Expression::createFromPattern($pattern);

    foreach(self::$_formats as $pos => $fmt)
    {
      if($pos > 4 && !isset($expression[$pos]))
      {
        continue;
      }

      $cmp = intval($time->format($fmt));

      $posSuccess = false;
      foreach($expression[$pos] as $part)
      {
        if($part['full'] == '*' || $part['full'] == $cmp || $posSuccess)
        {
          $posSuccess = true;
          break;
        }

        // process order: range, modulus

        // doesn't match val
        if(isset($part['val']) && $part['val'] != '*' && $cmp != $part['val'])
        {
          continue;
        }

        // out of range
        if(isset($part['min']) && isset($part['max']) && ($cmp < $part['min'] || $cmp > $part['max']))
        {
          continue;
        }

        $offset = isset($part['min']) ? $part['min'] : 0;
        if(isset($part['mod']) && (($cmp - $offset) % $part['mod']) != 0)
        {
          continue;
        }

        $posSuccess = true;
      }
      if(!$posSuccess)
      {
        return false;
      }
    }
    return true;
  }
public static function isDue ( $ pattern , \ DateTime $ time = null ) { if ( $ time === null ) { $ time = new \ DateTime ( ) ; } // trim time back to last round minute $ time -> setTime ( $ time -> format ( 'H' ) , $ time -> format ( 'i' ) ) ; $ expression = Expression :: createFromPattern ( $ pattern ) ; foreach ( self :: $ _formats as $ pos => $ fmt ) { if ( $ pos > 4 && ! isset ( $ expression [ $ pos ] ) ) { continue ; } $ cmp = intval ( $ time -> format ( $ fmt ) ) ; $ posSuccess = false ; foreach ( $ expression [ $ pos ] as $ part ) { if ( $ part [ 'full' ] == '*' || $ part [ 'full' ] == $ cmp || $ posSuccess ) { $ posSuccess = true ; break ; } // process order: range, modulus // doesn't match val if ( isset ( $ part [ 'val' ] ) && $ part [ 'val' ] != '*' && $ cmp != $ part [ 'val' ] ) { continue ; } // out of range if ( isset ( $ part [ 'min' ] ) && isset ( $ part [ 'max' ] ) && ( $ cmp < $ part [ 'min' ] || $ cmp > $ part [ 'max' ] ) ) { continue ; } $ offset = isset ( $ part [ 'min' ] ) ? $ part [ 'min' ] : 0 ; if ( isset ( $ part [ 'mod' ] ) && ( ( $ cmp - $ offset ) % $ part [ 'mod' ] ) != 0 ) { continue ; } $ posSuccess = true ; } if ( ! $ posSuccess ) { return false ; } } return true ; }
Returns true if the time matches the pattern supplied.
Time defaults to current time.

@param           $pattern
@param \DateTime $time

@return bool
Returns true if the time matches the pattern supplied . Time defaults to current time .