2017 © Pedro Peláez
 

library chronos

A simple API extension for DateTime.

image

cakephp/chronos

A simple API extension for DateTime.

  • Wednesday, July 11, 2018
  • by cakephp
  • Repository
  • 52 Watchers
  • 614 Stars
  • 2,485,562 Installations
  • PHP
  • 65 Dependents
  • 1 Suggesters
  • 39 Forks
  • 16 Open issues
  • 34 Versions
  • 21 % Grown

The README.md

CakePHP Chronos

Build Status Latest Stable Version Total Downloads Code Coverage Software License, (*1)

Chronos focuses on providing immutable date/datetime objects. Immutable objects help ensure that datetime objects aren't accidentally modified keeping data more predictable., (*2)

Installation

Installing with composer:, (*3)

$ composer require cakephp/chronos

You can then use Chronos:, (*4)

<?php
require 'vendor/autoload.php';

use Cake\Chronos\Chronos;

printf("Now: %s", Chronos::now());

Differences with nesbot/carbon

Chronos was originally compatible with Carbon but has diverged and no longer extends the PHP DateTime and DateTimeImmutable classes., (*5)

Immutable Object Changes

Immutable objects have a number of advantages:, (*6)

  1. Using immutable objects is always free of side-effects.
  2. Dates and times don't accidentally change underneath other parts of your code.

With those benefits in mind, there are a few things you need to keep in mind when modifying immutable objects:, (*7)

// This will lose modifications
$date = new Chronos('2015-10-21 16:29:00');
$date->modify('+2 hours');

// This will keep modifications
$date = new Chronos('2015-10-21 16:29:00');
$date = $date->modify('+2 hours');

Calendar Dates

PHP only offers datetime objects as part of the native extensions. Chronos adds a number of conveniences to the traditional DateTime object and introduces a ChronosDate object. ChronosDate instances their time frozen to 00:00:00 and the timezone set to the server default timezone. This makes them ideal when working with calendar dates as the time components will always match., (*8)

use Cake\Chronos\ChronosDate;

$today = new ChronosDate();
echo $today;
// Outputs '2015-10-21'

echo $today->modify('+3 hours');
// Outputs '2015-10-21'

Like instances of Chronos, ChronosDate objects are also immutable., (*9)

Documentation

A more descriptive documentation can be found at book.cakephp.org/chronos/3/en/., (*10)

API Documentation

API documentation can be found on api.cakephp.org/chronos., (*11)

The Versions

11/07 2018

dev-master

9999999-dev http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php ^5.5.9|^7

 

The Development Requires

date time datetime

11/07 2018

1.2.2

1.2.2.0 http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php ^5.5.9|^7

 

The Development Requires

date time datetime

11/07 2018

dev-strict-types

dev-strict-types http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php ^5.5.9|^7

 

The Development Requires

date time datetime

23/06 2018

1.2.1

1.2.1.0 http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php ^5.5.9|^7

 

The Development Requires

date time datetime

21/06 2018

1.2.0

1.2.0.0 http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php ^5.5.9|^7

 

The Development Requires

date time datetime

23/05 2018

dev-overwrite-us

dev-overwrite-us http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php ^5.5.9|^7

 

The Development Requires

date time datetime

01/03 2018

dev-phpstan-updates

dev-phpstan-updates http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php ^5.5.9|^7

 

The Development Requires

date time datetime

13/01 2018

1.1.4

1.1.4.0 http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php ^5.5.9|^7

 

The Development Requires

date time datetime

25/12 2017

1.1.3

1.1.3.0 http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php ^5.5.9|^7

 

The Development Requires

date time datetime

08/05 2017

dev-codesniffer-update

dev-codesniffer-update http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

date time datetime

27/04 2017

1.1.2

1.1.2.0 http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

date time datetime

31/03 2017

1.1.1

1.1.1.0 http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

date time datetime

15/02 2017

1.1.0

1.1.0.0 http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

date time datetime

09/01 2017

1.0.4

1.0.4.0 http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

date time datetime

21/12 2016

1.0.3

1.0.3.0 http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

date time datetime

09/12 2016

1.0.2

1.0.2.0 http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

date time datetime

15/11 2016

1.0.1

1.0.1.0 http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

date time datetime

14/07 2016

1.0.0

1.0.0.0 http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

date time datetime

15/06 2016

0.4.11

0.4.11.0 http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

date time datetime

14/06 2016

0.4.10

0.4.10.0 http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

date time datetime

16/04 2016

0.4.9

0.4.9.0 http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

date time datetime

10/03 2016

0.4.8

0.4.8.0 http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

date time datetime

14/02 2016

0.4.7

0.4.7.0 http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

date time datetime

07/02 2016

0.4.6

0.4.6.0 http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

date time datetime

02/01 2016

0.4.5

0.4.5.0 http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php >=5.5.10

 

The Development Requires

date time datetime

01/01 2016

0.4.4

0.4.4.0 http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php >=5.5.8

 

The Development Requires

date time datetime

06/12 2015

0.4.3

0.4.3.0 http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php >=5.5.8

 

The Development Requires

date time datetime

22/11 2015

0.4.2

0.4.2.0 http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

date time datetime

17/11 2015

0.4.1

0.4.1.0 http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

date time datetime

16/11 2015

0.4.0

0.4.0.0 http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

date time datetime

29/10 2015

0.3.0

0.3.0.0 http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

date time datetime

26/10 2015

0.2.0

0.2.0.0 http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

date time datetime

13/10 2015

dev-feature/remove-aliases

dev-feature/remove-aliases http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

date time datetime

12/10 2015

0.1.0

0.1.0.0 http://cakephp.org

A simple API extension for DateTime.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

date time datetime