该包已被弃用,不再维护。作者建议使用 cakephp/chronos 包。

PHP 日期和时间操作库

v0.1.0 2013-05-09 07:39 UTC

This package is auto-updated.

Last update: 2020-03-01 20:32:54 UTC


README

目标

方便安全 的 PHP 日期和时间处理方式。

优势

  • 丰富、易于理解(且易于记忆)的方法集。
  • 函数式习惯用法
    • 不可变集合(最安全且适用于大多数情况)。

安装

Clock 目前可以作为子模块安装到您的 Git 项目中

git submodule add git://github.com/alexeyshockov/clock.git vendor/clock

或者通过 Composer

{
    "require": {
        "alexeyshockov/clock": "dev-master"
    }
}

用法

一些示例

<?php

$period = new \DatePeriod('R5/2008-03-01T13:00:00Z/P1Y2M10DT2H30M');

// Converting period to collection of dates with Colada.
$dates = to_collection($period);

$formattedDates = $dates->mapBy(x()->format(\DateTime::ATOM));