The League of Extraordinary Packages

Our Packages:

Presented by The League of Extraordinary Packages

Getting Started


Upgrading Guide

This is the documentation for the upcoming version 4.0. This is a work in progress


Date and time references


At his core the Period class only uses DateTimeImmutable and DateInterval objects. But because it is sometime complicated to get your hands on such objects the package comes bundles with two simple functions that are used throughout the library to ensure typesafety.

WARNING: When the string is not parsable by DateInterval::createFromDateString a DateInterval object representing the 0 interval is returned.



use function League\Period\datepoint;
use function League\Period\duration;

$datePeriod = new DatePeriod(
	datepoint(new DateTime('+3 WEEKS'))

//returns the same object as if you had written

$datePeriod = new DatePeriod(
	new DateTimeImmutable('YESTERDAY'),
	new DateInterval('PT600S'),
	new DateTimeImmutable('+3 WEEKS')

Theses functions are used by the Period class and the helper functions to allow broader input acceptance.