src/Utilities/Date.php
public static function isValidDateFormat($format)
    {
        if (empty($format) || !is_string($format)) {
            return false;
        }

        $formatted = (new DateTime())->format($format);

        // Formatted date it's the format who is validated?
        // The format is invalid
        if ($formatted === $format) {
            return false;
        }

        // Validate the format used to create the datetime
        $fromFormat = DateTime::createFromFormat($format, $formatted);

        // It's instance of DateTime?
        // The format is valid
        if ($fromFormat instanceof DateTime) {
            return true;
        }

        return $fromFormat instanceof DateTime;
    }
public static function isValidDateFormat($format)
    {
        if (empty($format) || !is_string($format)) {
            return false;
        }

        $formatted = (new DateTime())->format($format);

        // Formatted date it's the format who is validated?
        // The format is invalid
        if ($formatted === $format) {
            return false;
        }

        // Validate the format used to create the datetime
        $fromFormat = DateTime::createFromFormat($format, $formatted);

        // It's instance of DateTime?
        // The format is valid
        if ($fromFormat instanceof DateTime) {
            return true;
        }

        return $fromFormat instanceof DateTime;
    }
public static function isValidDateFormat ( $ format ) { if ( empty ( $ format ) || ! is_string ( $ format ) ) { return false ; } $ formatted = ( new DateTime ( ) ) -> format ( $ format ) ; // Formatted date it's the format who is validated? // The format is invalid if ( $ formatted === $ format ) { return false ; } // Validate the format used to create the datetime $ fromFormat = DateTime :: createFromFormat ( $ format , $ formatted ) ; // It's instance of DateTime? // The format is valid if ( $ fromFormat instanceof DateTime ) { return true ; } return $ fromFormat instanceof DateTime ; }
Returns information if given format of date is valid

@param string $format The validated format of date
@return bool
Returns information if given format of date is valid