定制 comsolit/date-time-immutable 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

comsolit/date-time-immutable

最新稳定版本:v2.0.0+alpha1

Composer 安装命令:

composer require comsolit/date-time-immutable

包简介

Polyfill for the DateTimeImmutable class added in PHP 5.5.0

README 文档

README

Build Status

This small library adds a polyfill for the DateTimeImmutable object introduced in PHP 5.5.0.

Authors

  • Chris Wilkinson

It's partially based on Benjamin Eberlei's Immutable DateTime Objects blog post.

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).

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

统计信息

  • 总下载量: 42
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 9
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-03-19