jeskew / datetimeinterface-shim
A shim for using PHP >=5.5's DateTimeInterface in a PHP >=5.3 application
Installs: 19
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/jeskew/datetimeinterface-shim
Requires
- php: >=5.3.0
- nesbot/carbon: ^1.21
Requires (Dev)
- phpunit/phpunit: ^4.8
This package is auto-updated.
Last update: 2025-09-29 01:47:16 UTC
README
Stuck on PHP 5.3 or 5.4 but want to typehint against \DateTimeInterface
?
Install this package and use
the included DateTime class:
<?php 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