jeskew/datetimeinterface-shim

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

0.1.0 2015-11-15 20:33 UTC

This package is auto-updated.

Last update: 2024-03-29 02:52:59 UTC


README

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:

<?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