No need to make it dynamic (and thus requiring a version check). The check can be:

```php
if ($date instanceof DateTime || $date instanceof DateTimeInterface) {
```

The instanceof check does not require the class to exist (it does not try to autoload it but inspects the list of parent classes and implemented interfaces of the object). A check based on a non-existent class will simply return false