src/ResourceValidationsTrait.php
protected function cleanDateTimeValue($val)
    {
        // Uninterpretable values get returned as is
        if ((is_string($val) && substr($val, 0, 4) === '0000') || $val === false) {
            return $val;
        }

        // null and null-equivalent get returned as null
        if ($val === '' || $val === null) {
            return null;
        }

        // For everything else, we try to make a date out of it
        try {
            if (is_numeric($val)) {
                $val = new \DateTime("@".$val);
            } else {
                $val = new \DateTime($val);
            }
            return $val;
        } catch (\Throwable $e) {
            return $val;
        }
    }
protected function cleanDateTimeValue($val)
    {
        // Uninterpretable values get returned as is
        if ((is_string($val) && substr($val, 0, 4) === '0000') || $val === false) {
            return $val;
        }

        // null and null-equivalent get returned as null
        if ($val === '' || $val === null) {
            return null;
        }

        // For everything else, we try to make a date out of it
        try {
            if (is_numeric($val)) {
                $val = new \DateTime("@".$val);
            } else {
                $val = new \DateTime($val);
            }
            return $val;
        } catch (\Throwable $e) {
            return $val;
        }
    }
protected function cleanDateTimeValue ( $ val ) { // Uninterpretable values get returned as is if ( ( is_string ( $ val ) && substr ( $ val , 0 , 4 ) === '0000' ) || $ val === false ) { return $ val ; } // null and null-equivalent get returned as null if ( $ val === '' || $ val === null ) { return null ; } // For everything else, we try to make a date out of it try { if ( is_numeric ( $ val ) ) { $ val = new \ DateTime ( "@" . $ val ) ; } else { $ val = new \ DateTime ( $ val ) ; } return $ val ; } catch ( \ Throwable $ e ) { return $ val ; } }
Attempts to convert an integer or string into a DateTime object

@param mixed $val The value to clean
@return mixed A DateTime object or the original value, if not coercible
Attempts to convert an integer or string into a DateTime object