Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cakephp/chronos
A standalone DateTime library originally based off of Carbon
https://github.com/cakephp/chronos
calendar-dates datetime-objects immutable-objects library mutable-objects php time
Last synced: 2 days ago
JSON representation
A standalone DateTime library originally based off of Carbon
- Host: GitHub
- URL: https://github.com/cakephp/chronos
- Owner: cakephp
- License: mit
- Created: 2015-09-16T13:30:45.000Z (about 9 years ago)
- Default Branch: 3.x
- Last Pushed: 2024-09-20T02:48:48.000Z (3 months ago)
- Last Synced: 2024-10-29T11:24:49.730Z (about 1 month ago)
- Topics: calendar-dates, datetime-objects, immutable-objects, library, mutable-objects, php, time
- Language: PHP
- Homepage: http://book.cakephp.org/chronos
- Size: 1.24 MB
- Stars: 1,356
- Watchers: 44
- Forks: 63
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-php - Chronos - A DateTime API extension supporting both mutable and immutable date/time. (Table of Contents / Date and Time)
- awesome-cakephp - Chronos - A simple standalone DateTime API extension (successor of Carbon). (Libs)
- awesome-php-cn - Chronos - 一个DateTime API扩展支持可变和不可变的日期/时间. (目录 / 日期和时间 Date and Time)
- awesome-projects - Chronos - A DateTime API extension supporting both mutable and immutable date/time. (PHP / Date and Time)
- awesome-php - Chronos - A DateTime API extension supporting both mutable and immutable date/time. (Table of Contents / Date and Time)
README
# CakePHP Chronos
![Build Status](https://github.com/cakephp/chronos/actions/workflows/ci.yml/badge.svg?branch=master)
[![Latest Stable Version](https://img.shields.io/github/v/release/cakephp/chronos?sort=semver&style=flat-square)](https://packagist.org/packages/cakephp/chronos)
[![Total Downloads](https://img.shields.io/packagist/dt/cakephp/chronos?style=flat-square)](https://packagist.org/packages/cakephp/chronos/stats)
[![Code Coverage](https://img.shields.io/coveralls/cakephp/chronos/master.svg?style=flat-square)](https://coveralls.io/r/cakephp/chronos?branch=master)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)Chronos focuses on providing immutable date/datetime objects.
Immutable objects help ensure that datetime objects aren't accidentally
modified keeping data more predictable.# Installation
Installing with composer:
```
$ composer require cakephp/chronos
```You can then use Chronos:
```php
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.```php
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*.
# Documentation
A more descriptive documentation can be found at [book.cakephp.org/chronos/3/en/](https://book.cakephp.org/chronos/3/en/).
# API Documentation
API documentation can be found on [api.cakephp.org/chronos](https://api.cakephp.org/chronos).