src/Filter/StringToTime.php
public function filter($value)
    {

        // If it's already a timestamp, return it as is.
        if (preg_match('/^-?\d+$/', $value) === 1) {
            if ($value < 0) {
                throw new \DomainException('Invalid value');
            }
            return $value;
        }

        // Allow SQL specials.
        if ($this->getConfig('allowSqlSpecials') === true) {
            $temp = strtolower($value);
            if ($temp === 'now()' || $temp === 'current_timestamp') {
                return time();
            }
        }

        // Catch invalid strings.
        $time = strtotime($value);
        if ($time === false) {
            throw new \DomainException('Invalid value');
        }

        return $time;

    }
public function filter($value)
    {

        // If it's already a timestamp, return it as is.
        if (preg_match('/^-?\d+$/', $value) === 1) {
            if ($value < 0) {
                throw new \DomainException('Invalid value');
            }
            return $value;
        }

        // Allow SQL specials.
        if ($this->getConfig('allowSqlSpecials') === true) {
            $temp = strtolower($value);
            if ($temp === 'now()' || $temp === 'current_timestamp') {
                return time();
            }
        }

        // Catch invalid strings.
        $time = strtotime($value);
        if ($time === false) {
            throw new \DomainException('Invalid value');
        }

        return $time;

    }
public function filter ( $ value ) { // If it's already a timestamp, return it as is. if ( preg_match ( '/^-?\d+$/' , $ value ) === 1 ) { if ( $ value < 0 ) { throw new \ DomainException ( 'Invalid value' ) ; } return $ value ; } // Allow SQL specials. if ( $ this -> getConfig ( 'allowSqlSpecials' ) === true ) { $ temp = strtolower ( $ value ) ; if ( $ temp === 'now()' || $ temp === 'current_timestamp' ) { return time ( ) ; } } // Catch invalid strings. $ time = strtotime ( $ value ) ; if ( $ time === false ) { throw new \ DomainException ( 'Invalid value' ) ; } return $ time ; }
Convert a string to a timestamp.

@param string $value A string to convert to a timestamp.

@return integer The converted timestamp.
Convert a string to a timestamp .