src/Filter/DateTime.php
public static function filter($value, bool $allowNull = false, DateTimeZoneStandard $timezone = null)
    {
        if (self::valueIsNullAndValid($allowNull, $value)) {
            return null;
        }

        if ($value instanceof DateTimeStandard) {
            return $value;
        }

        if (is_int($value) || ctype_digit($value)) {
            $value = "@{$value}";
        }

        if (!is_string($value) || trim($value) == '') {
            throw new FilterException('$value is not a non-empty string');
        }

        return new DateTimeStandard($value, $timezone);
    }
public static function filter($value, bool $allowNull = false, DateTimeZoneStandard $timezone = null)
    {
        if (self::valueIsNullAndValid($allowNull, $value)) {
            return null;
        }

        if ($value instanceof DateTimeStandard) {
            return $value;
        }

        if (is_int($value) || ctype_digit($value)) {
            $value = "@{$value}";
        }

        if (!is_string($value) || trim($value) == '') {
            throw new FilterException('$value is not a non-empty string');
        }

        return new DateTimeStandard($value, $timezone);
    }
public static function filter ( $ value , bool $ allowNull = false , DateTimeZoneStandard $ timezone = null ) { if ( self :: valueIsNullAndValid ( $ allowNull , $ value ) ) { return null ; } if ( $ value instanceof DateTimeStandard ) { return $ value ; } if ( is_int ( $ value ) || ctype_digit ( $ value ) ) { $ value = "@{$value}" ; } if ( ! is_string ( $ value ) || trim ( $ value ) == '' ) { throw new FilterException ( '$value is not a non-empty string' ) ; } return new DateTimeStandard ( $ value , $ timezone ) ; }
Filters the given value into a \DateTime object.

@param mixed                $value     The value to be filtered.
@param boolean $allowNull              True to allow nulls through, and false (default) if nulls should
not be allowed.
@param DateTimeZoneStandard $timezone  A \DateTimeZone object representing the timezone of $value.
If $timezone is omitted, the current timezone will be used.

@return DateTimeStandard|null

@throws FilterException if the value did not pass validation.
Filters the given value into a \ DateTime object .