public static function validate($string)
    {
        try {
            if (is_numeric($string) && (int)$string == $string) {
                $date = new DateTime('@' . $string);
            } else {
                $date = self::parse($string);
            }
        } catch (Exception $ex) {
            return false;
        }

        // String is empty or not a valid date
        if (empty($string) || $date === false) {
            return false;

            // String is a valid date
        } else {
            return true;
        }
    }
public static function validate($string)
    {
        try {
            if (is_numeric($string) && (int)$string == $string) {
                $date = new DateTime('@' . $string);
            } else {
                $date = self::parse($string);
            }
        } catch (Exception $ex) {
            return false;
        }

        // String is empty or not a valid date
        if (empty($string) || $date === false) {
            return false;

            // String is a valid date
        } else {
            return true;
        }
    }
public static function validate ( $ string ) { try { if ( is_numeric ( $ string ) && ( int ) $ string == $ string ) { $ date = new DateTime ( '@' . $ string ) ; } else { $ date = self :: parse ( $ string ) ; } } catch ( Exception $ ex ) { return false ; } // String is empty or not a valid date if ( empty ( $ string ) || $ date === false ) { return false ; // String is a valid date } else { return true ; } }
Validate a given date and time string

@param string $string
A date and time string or timestamp to validate
@return boolean
Returns true for valid dates, otherwise false
Validate a given date and time string