- Requires: PHP >= 5.5.0
- Release Date: 2015-09-02
- Supported Until: TBD
<?php date_default_timezone_set('UTC'); use League\Period\Period; $period = Period::createFromDuration('2014-10-03 08:12:37', 3600); $start = $period->getStartDate(); $end = $period->getEndDate(); $duration = $period->getDateInterval(); $altPeriod = $period->endingOn('2014-12-03'); $period->contains($altPeriod); //return false; $altPeriod->durationGreaterThan($period); //return true;
Period is PHP's missing Time Range class. It is based on Resolving Feature Envy in the Domain by Mathias Verraes and extends the concept to cover all basic operations regarding time ranges.
Treats Time Range as immutable value objects
Exposes many named constructors to ease time range creation
Covers all basic manipulations related to time range
Once a new major version is released, the previous stable release remains supported for six (6) more months through patches and/or security fixes.
League\Period was created by Ignace Nyamagana Butera. Find him on Twitter at @nyamsprod.