A shim for using PHP >=5.5's DateTimeInterface in a PHP >=5.3 application

0.1.0 2015-11-15 20:33 UTC


Build Status GitHub license Packagist

Stuck on PHP 5.3 or 5.4 but want to typehint against \DateTimeInterface? Install this package and use the included DateTime class:


use DateTimeCompat\DateTime;

$now = new DateTime();
$fromFormat = DateTime::fromFormat('U', (string) time());

Already have an instance of \DateTime? This package uses nesbot/carbon under the hood, so all of its convenience methods are available to you, including instance:

DateTime::instance(new \DateTime) instanceof 'DateTimeInterface' === true