cakephp/chronos
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
CakePHP Chronos is a PHP package that offers an API extension for DateTime. It focuses on providing immutable date and datetime objects, ensuring that these objects aren't accidentally modified thus keeping data more predictable. It is especially useful when dealing with calendar dates where time components need to always match. The time on these dates is frozen at '00:00:00' and the timezone is set to the server default. This PHP extension package is ideal for anyone dealing with dates and times in their code as it simplifies the management and manipulation of these data types.
To install and use CakePHP Chronos, begin by installing it with Composer using the command: composer require cakephp/chronos
. After the installation, you can use Chronos in your PHP file as follows:
<?php
require 'vendor/autoload.php';
use Cake\Chronos\Chronos;
printf("Now: %s", Chronos::now());
You can use the modify
function to modify dates, keeping in mind your changes should be reassigned to a variable to be saved since Chronos creates immutable objects. For example:
<?php
$date = new Chronos('2015-10-21 16:29:00');
$date = $date->modify('+2 hours');
Additionally, handling calendar dates is also simplified:
<?php
use Cake\Chronos\ChronosDate;
$today = new ChronosDate();
echo $today;
// Outputs '2015-10-21'
echo $today->modify('+3 hours');
// Outputs '2015-10-21'
The documentation for CakePHP Chronos can be found at book.cakephp.org/chronos/3/en/. This will give you a more descriptive outline of how this package functions. The API documentation is available at api.cakephp.org/chronos. These resources will help you navigate the usage and implementation of Chronos in your PHP applications.