public static function isDateTime($date, string $format = null): bool
    {
        if ($date instanceof \DateTime) {
            return true;
        }

        if (false === is_string($date)) {
            return false;
        }

        if ($format) {
            return \DateTime::createFromFormat($format, $date) instanceof \DateTime;
        }

        return (bool)strtotime($date);
    }
public static function isDateTime($date, string $format = null): bool
    {
        if ($date instanceof \DateTime) {
            return true;
        }

        if (false === is_string($date)) {
            return false;
        }

        if ($format) {
            return \DateTime::createFromFormat($format, $date) instanceof \DateTime;
        }

        return (bool)strtotime($date);
    }
public static function isDateTime ( $ date , string $ format = null ) : bool { if ( $ date instanceof \ DateTime ) { return true ; } if ( false === is_string ( $ date ) ) { return false ; } if ( $ format ) { return \ DateTime :: createFromFormat ( $ format , $ date ) instanceof \ DateTime ; } return ( bool ) strtotime ( $ date ) ; }
Checks if given value is a valid PHP "datetime"

@param string|\DateTime $date
@param string|null      $format

@return bool
Checks if given value is a valid PHP datetime