2017 © Pedro Peláez
 

library date-time-immutable

Polyfill for the DateTimeImmutable class added in PHP 5.5.0

image

thewilkybarkid/date-time-immutable

Polyfill for the DateTimeImmutable class added in PHP 5.5.0

  • Thursday, October 23, 2014
  • by thewilkybarkid
  • Repository
  • 2 Watchers
  • 0 Stars
  • 888 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 1 Forks
  • 2 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

DateTimeImmutable polyfill

Build Status, (*1)

This small library adds a polyfill for the DateTimeImmutable object introduced in PHP 5.5.0., (*2)

Authors

  • Chris Wilkinson

It's partially based on Benjamin Eberlei's Immutable DateTime Objects blog post., (*3)

Installation

$ php composer.phar require thewilkybarkid/date-time-immutable:~1.0

Basic usage

$dateTime = new DateTimeImmutable();
$newDateTime = $datetime->modify('+1 day');
var_dump($dateTime === $newDateTime); // output 'bool(false)'

Caveats

PHP 5.5.0 also introduced a DateTimeInterface which both DateTimeImmutable and DateTime implement. In this polyfill we can't change the DateTime class, so DateTimeImmutable has to extend it. This is slightly dangerous as their behaviour is not compatible (see https://bugs.php.net/bug.php?id=64513)., (*4)

PHP 5.6.0 added a DateTimeImmutable::createFromMutable() factory method, which this polyfill doesn't include., (*5)

The Versions

23/10 2014

dev-master

9999999-dev https://github.com/thewilkybarkid/date-time-immutable

Polyfill for the DateTimeImmutable class added in PHP 5.5.0

  Sources   Download

MIT

The Requires

  • php >=5.2.0

 

The Development Requires

by Avatar thewilkybarkid

23/10 2014

v1.0.2

1.0.2.0 https://github.com/thewilkybarkid/date-time-immutable

Polyfill for the DateTimeImmutable class added in PHP 5.5.0

  Sources   Download

MIT

The Requires

  • php >=5.2.0

 

The Development Requires

by Avatar thewilkybarkid

21/10 2014

v1.0.1

1.0.1.0 https://github.com/thewilkybarkid/date-time-immutable

Polyfill for the DateTimeImmutable class added in PHP 5.5.0

  Sources   Download

MIT

The Requires

  • php >=5.2.0

 

The Development Requires

by Avatar thewilkybarkid

11/11 2013

v1.0.0

1.0.0.0 https://github.com/thewilkybarkid/date-time-immutable

Polyfill for the DateTimeImmutable class added in PHP 5.5.0

  Sources   Download

MIT

The Requires

  • php >=5.2.0

 

The Development Requires

by Chris Wilkinson