This is the documentation for version 4.0 which will be supported until 2022-08-21. Please consider upgrading your code to the latest stable version

Installation

System Requirements

Period requires PHP 7.2.5 but the latest stable version of PHP.

Since version 4.10 support for PHP 7.1.x is dropped.

Composer

Period is available on Packagist and can be installed using Composer.

$ composer require league/period

Going Solo

You can also use Period without using Composer by downloading the library and:

  • using any other PSR-4 compatible autoloader.
  • using the bundle autoloader script as shown below:
require 'path/to/league/repo/autoload.php';

use League\Period\Datepoint;

Datepoint::create('2012-05-23')->getDay()->getEndDate();
//returns DateTimeImmutable('2012-05-24 00:00:00.000000');

where path/to/league/repo represents the path where the library was extracted.