NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Packagist · #2473 most downloaded on Packagist
Time range API for PHP
Last release 12 days ago
25 Sep 2026
Ships fairly regularly
a new release about every 8 months
Nearly every release is documented
notes for 46 of 46 stable releases
Nothing withdrawn
no release was ever pulled
12 years old
46 releases · first in 2014
Fix inconsistent behaviour in Duration named constructor #141
Time\DurationDuration named constructor #141PHP8.1 supportFull Changelog: 5.3.3...5.4.0
Fix inconsistent behaviour for isBefore() when comparing periods with other periods or dates #138 thanks @brummbar
One column per quarter.
Fix package to avoid PHP8.4 deprecation warnings
Fix Period duplication during intersection calculation #135 by maogou
Handles gracefully new Date exception in PHP8.3
Chart\LetterCase::convertPeriod::fromRange should work in PHP8.1 with DatePeriod limitations.
Period::fromRange should work in PHP8.1 with DatePeriod limitations.InitialDatePresence use instead Period::fromRangePeriod::rangeForward allows iteration over a set of dates and times, recurring at regular intervals, over the instance forward starting from the insta
Period::rangeForward allows iteration over a set of dates and times, recurring at regular intervals, over the instance forward starting from the instance start.Period::rangeBackwards Allows iteration over a set of dates and times, recurring at regular intervals, over the instance backwards starting from the instance ending.Period::fromRange returns a new Period instance from a DatePeriod object. Only usable in PHP8.2+ installationPeriod::dateRangeForward use instead Period::rangeForwardPeriod::dateRangeBackwards use instead Period::rangeBackwardsDatePoint::fromFormat to instantiate from a date format and its related string.
DatePoint::fromFormat to instantiate from a date format and its related string.Period::fromIso8601 now supports truncated date and duration in the interval string.IntervalError used as the error interface marker.
IntervalError used as the error interface marker.InvalidInterval exception for anything regarding creating an object.Duration::fromSeconds uses a dedicated fraction parameter and the seconds are no longer expressed using a float value.Period::fromTimestamp to instantiate a time range object from two timestamps.Period::fromIso80000 to instantiate a time range object from a mathematical representation and a date format.Period::fromBourbaki to instantiate a time range object from a mathematical representation and a date format.Period duration comparison methods accepts also Duration and DateInterval in addition to Period objects.Period::unionPeriod::snapTo* methods to ease period expansion.Period::meetsPeriod::meetsOnStartPeriod::meetsOnEndPeriod::toBourbakiPeriod::toIso80000Period::toBourbakiBounds Enumeration.InitialDatePresence Enumeration.Sequence::toListChart\LetterCase Enumeration.Chart\Alignment Enumeration.Chart\StreamOutput class to replace Chart\ConsoleOutput class.Chart\Terminal Enumeration.Chart\ChartError used as the chart error interface marker.Chart\UnableToDrawChart exception for anything regarding drawing a chart out of Period and/or Sequence objects.Closure object instead of the callable pseudo type with the Sequence methods.Period::diff returns a Sequence instance instead of an array.Period::__construct is private.Period named constructors, all parameters are required except for the boundaries.Period::timeDuration now returns an int instead of a float value.Period::intersect now can take multiple Period instances as parameters.Period::subtract now can take multiple Period instances as parameters.Duration no longer extends a DateInterval object.Duration::fromIsoString supports 3 versions of dealing with fractions with ISO valid string.Datepoint class renamed DatePoint.DatePoint no longer extends a DateTimeImmutable object.Chart\LatinLetter in case of wrong value will fall back to A instead of 0 which is not a letter.Chart\LatinLetter the starting label must be explicit on instantiation.Chart\RomanNumber requires its two arguments to be explicitly set.Period::fromDatepoint replaced by Period::fromDatePeriod::getStartDate replaced by accessing readonly property Period::startDatePeriod::getEndDate replaced by accessing readonly property Period::endDatePeriod::getBoundaryType replaced by accessing readonly property Period::boundsPeriod::getDateInterval replaced by Period::dateIntervalPeriod::getTimestampInterval replaced by Period::timeDurationPeriod::withBoundaryType replaced by Period::boundedByPeriod::isStartIncluded with no replacement use Bounds::isStartIncludedPeriod::isStartExcluded with no replacement use Bounds::isStartIncluded insteadPeriod::isEndIncluded with no replacement use Bounds::isEndIncludedPeriod::isEndExcluded with no replacement use Bounds::isEndIncluded insteadPeriod::fromDatePeriod replaced by Period::fromDateRangePeriod::getDatePeriod replaced by Period::dateRangePeriod::getDatePeriodBackwards replaced by Period::dateRangeBackwardsPeriod::__string replaced by Period::toIso8601Period::format replaced by Period::toIso80000Period::split replaced by Period::splitForwardPeriod::substract use Period::subtract insteadSequence::substract use Sequence::subtract insteadSequence::getIntersections use Sequence::intersections insteadSequence::getGaps use Sequence::gaps insteadSequence::getBoundaries use Sequence::length insteadSequence::getTotalTimestampInterval use Sequence::totalTimeDuration insteadSequence::toArray use Sequence::toList insteadDuration::__toString and Duration::format with no replacementDuration::create is removed with no replacementDatepoint::create is removed with no replacementcreate prefix is removed from the Duration and Datepoint named constructors.Chart\ConsoleOutput replaced by Chart\StreamOutput class.Chart\RomanNumber::isLower use Chart\LetterCase::isUpper instead.Chart\RomanNumber::startingAt use Chart\DecimalNumber::startLabel public readonly propertyChart\RomanNumber::startsWith is removed with no replacementChart\RomanNumber::withLetterCase is removed with no replacementChart\DecimalNumber::startsWith is removed with no replacementChart\LatinNumber::startsWith is removed with no replacementChart\LatinNumber::startingAt use Chart\LatinNumber::startLabel public readonly propertyChart\AffixLabel::withPrefix is removed with no replacementChart\AffixLabel::withSuffix is removed with no replacementChart\AffixLabel::prefix method use Chart\AffixLabel::labelPrefix public readonly propertyChart\AffixLabel::suffix method use Chart\AffixLabel::labelSuffix public readonly propertyRemoved all the following namespaced functions from the package:
League\Period\datepointLeague\Period\durationLeague\Period\yearLeague\Period\semesterLeague\Period\quarterLeague\Period\monthLeague\Period\dayLeague\Period\hourLeague\Period\minuteLeague\Period\secondLeague\Period\instantLeague\Period\iso_yearLeague\Period\iso_weekLeague\Period\interval_afterLeague\Period\interval_beforeLeague\Period\interval_aroundLeague\Period\interval_from_dateperiodDatepoint::getSecond is deprecated in favor of Datepoint::second
Datepoint::secondDatepoint::minuteDatepoint::hourDatepoint::isoWeekDatepoint::monthDatepoint::quarterDatepoint::semesterDatepoint::yearDatepoint::isoYearDuration::fromDateIntervalDuration::fromSecondsDuration::fromChronoStringDuration::fromTimeStringDuration::fromDateStringPeriod::timeDurationPeriod::dateIntervalPeriod::dateRangeForwardPeriod::dateRangeBackwardsPeriod::toIso80000Period::splitForwardPeriod::timeDurationDiffPeriod::boundedBySequence::lengthSequence::totalTimeDurationDatepoint::getSecond is deprecated in favor of Datepoint::secondDatepoint::getMinute is deprecated in favor of Datepoint::minuteDatepoint::getHour is deprecated in favor of Datepoint::hourDatepoint::getIsoWeek is deprecated in favor of Datepoint::isoWeekDatepoint::getMonth is deprecated in favor of Datepoint::monthDatepoint::getQuarter is deprecated in favor of Datepoint::quarterDatepoint::getSemester is deprecated in favor of Datepoint::semesterDatepoint::getYear is deprecated in favor of Datepoint::yearDatepoint::getIsoYear is deprecated in favor of Datepoint::isoYearDuration::createfromDateInterval is deprecated in favor of Datepoint::fromDateIntervalDuration::createfromSeconds is deprecated in favor of Datepoint::fromSecondsDuration::createfromChronoString is deprecated in favor of Datepoint::fromChronoStringDuration::createfromTimeString is deprecated in favor of Datepoint::fromTimeStringDuration::createfromDateString is deprecated in favor of Datepoint::fromDateStringPeriod::getTimestampInterval is deprecated in favor of Period::timeDurationPeriod::getDateInterval is deprecated in favor of Period::dateIntervalPeriod::getDatePeriod is deprecated in favor of Period::dateRangeForwardPeriod::getDatePeriodBackwards is deprecated in favor of Period::dateRangeBackwardsPeriod::format is deprecated in favor of Period::toIso80000Period::split is deprecated in favor of Period::splitForwardPeriod::withBoundaryType is deprecated in favor of Period::boundedByPeriod::timestampIntervalDiff is deprecated in favor of Period::timeDurationDiffSequence::boundaries is deprecated in favor of Sequence::lengthSequence::getTotalTimestampInterval is deprecated in favor of Sequence::totalTimeDurationDuration::createFromDateInterval
Period::fromDatepointDuration::createFromDateIntervalDuration::createFromTimeStringDuration::createFromChronoStringDuration::createFromSecondsDuration::create supports DateInterval spec strings.Duration::create when using a float will now overflow the results up to the Hour unit.Charts featuring ported from Bakame\Period\Vizualizer
Period::toIso8601Sequence::intersections method.Period::__string replaced by Period::toIso8601$boundaryType argument added to the following named constructors:
$boundaryType argument added to the following named constructors:
Period::fromDayPeriod::fromIsoWeekPeriod::fromMonthPeriod::fromQuarterPeriod::fromSemesterPeriod::fromYearPeriod::fromIsoYearPeriod::subtract
Sequence::subtract
Period::substract use Period::subtract insteadSequence::substract use Sequence::subtract insteadSequence negative offsets for a object with only one Period instance issue #85
Sequence negative offsets for a object with only one Period instance issue #85Datepoint methods returning Period objects supports boundaryType
Datepoint methods returning Period objects supports boundaryTypePeriod::merge supports empty arguments.Sequence::contains supports empty arguments.Sequence::unshift supports empty arguments.Sequence::push supports empty arguments.Sequence class supports negative offsets.Duration::adjustedTo no longer compares DateInterval objects to be compatible with PHP7.4+Improve Duration::createFromDateString bug fix to take into account DateInterval::createFromDateString bug fix
Duration::createFromDateString bug fix to take into account DateInterval::createFromDateString
bug fixSequence::getTotalTimestampInterval see PR #79
Sequence::getTotalTimestampInterval see PR #79Period::substract see PR #80Sequence::substract see PR #81Duration::createFromDateString to take into account DateInterval::createFromDateString
bug fixInternals: added support for PHP7.4 and PHP8.0 in travis.yml
Duration::adjustedToDuration::withoutCarryOver use Duration::adjustedTo insteadDuration::create now supports chronometer format
Datepoint::isBeforeDatepoint::bordersOnStartDatepoint::isStartingDatepoint::isDuringDatepoint::isEndingDatepoint::bordersOnEndDatepoint::isAfterDatepoint::abutsDuration::create now supports chronometer formatDuration::withoutCarryOverPeriod::durationCompare to take into account Timezone and DSTDuration::__toString use Duration::format insteadAdded support for the boundary type
Period::EXCLUDE_START_INCLUDE_ENDPeriod::INCLUDE_START_EXCLUDE_ENDPeriod::EXCLUDE_ALLPeriod::INCLUDE_ALLPeriod::getBoundaryTypePeriod::isStartExcludedPeriod::isStartIncludedPeriod::isEndExcludedPeriod::isEndIncludedPeriod::withBoundaryTypePeriod::__construct adds the $boundaryType argument;Period::after adds the $boundaryType argument;Period::before adds the $boundaryType argument;Period::around adds the $boundaryType argument;Period::fromDatePeriod adds the $boundaryType argument;Period::bordersOnStartPeriod::bordersOnEndPeriod::isDuringPeriod::isStartedByPeriod::isEndedBySequence::unionsSequence::intersectionsSequence::gapsSequence::boundariesSequence::reduceSequence::getIntersections use Sequence::intersections insteadSequence::getGaps use Sequence::gaps insteadSequence::getBoundaries use Sequence::boundaries insteadDatepoint::createFromFormat see issue #72
Sequence implements the ArrayAccess interface
Sequence implements the ArrayAccess interfaceSequence::map must preserve offset index after modification.League\Period\interval_from_dateperiod
League\Period\DatepointLeague\Period\DurationPeriod::fromIsoYearPeriod::fromYearPeriod::fromSemesterPeriod::fromQuarterPeriod::fromMonthPeriod::fromIsoWeekPeriod::fromDayPeriod::afterPeriod::beforePeriod::aroundPeriod::fromDatePeriodSequence::mapLeague\Period\datepointLeague\Period\durationLeague\Period\yearLeague\Period\semesterLeague\Period\quarterLeague\Period\monthLeague\Period\dayLeague\Period\hourLeague\Period\minuteLeague\Period\secondLeague\Period\instantLeague\Period\iso_yearLeague\Period\iso_weekLeague\Period\interval_afterLeague\Period\interval_beforeLeague\Period\interval_aroundLeague\Period\interval_from_dateperiod### Added - League\Period\Sequence - League\Period\InvalidIndex ### Fixed - None ### Deprecated - None ### Removed - None
League\Period\SequenceLeague\Period\InvalidIndexPeriod::split does not work with daylight saving see issue #68
Period::split does not work with daylight saving see issue #68League\Period\interval_from_dateperiod
Exception classPeriod::durationComparePeriod::durationEqualsPeriod::formatPeriod::expandPeriod::equalsPeriod::getDatePeriodBackwardsLeague\Period\datepointLeague\Period\durationLeague\Period\yearLeague\Period\semesterLeague\Period\quarterLeague\Period\monthLeague\Period\dayLeague\Period\hourLeague\Period\minuteLeague\Period\secondLeague\Period\instantLeague\Period\iso_yearLeague\Period\iso_weekLeague\Period\interval_afterLeague\Period\interval_beforeLeague\Period\interval_aroundLeague\Period\interval_from_dateperiodPeriod class is now finalPeriod::JsonSerialize now returns datepoint in JavaScript compatible notationPeriod::diff always returns an array containing two values.DateInterval('PT0S') will contains no datepoint not even its starting datepoint.7.0Period::nextPeriod::previousPeriod::addPeriod::subPeriod::createFromYear replaced by League\Period\yearPeriod::createFromMonth replaced by League\Period\monthPeriod::createFromWeek replaced by League\Period\iso_weekPeriod::createFromDay replaced by League\Period\dayPeriod::createFromSemester replaced by League\Period\semesterPeriod::createFromQuarter replaced by League\Period\quarterPeriod::createFromDuration replaced by League\Period\interval_afterPeriod::createFromDurationBeforeEnd replaced by League\Period\interval_beforePeriod::sameValueAs replaced by Period::equalsPeriod::sameDurationAs replaced by Period::durationEqualsPeriod::compareDuration replaced by Period::durationComparePeriod::withDuration replaced by Period::withDurationAfterStart### Added - Period::withDurationBeforeEnd - Period::splitBackwards ### Fixed - None ### Deprecated - None ### Removed - None
Period::withDurationBeforeEndPeriod::splitBackwardsPeriod::add you should use Period::moveEndDate instead
Period::movePeriod::moveStartDatePeriod::moveEndDatePeriod::add you should use Period::moveEndDate insteadPeriod::sub you should use Period::moveEndDate insteadautoloader to use the library without composer
microseconds are taken into account when converting DateTimeInterface objects.
Period::contains see issue #31DateTimeInterface objects.Period::getDatePeriod adding the $option parameter
Period::createFromDayPeriod::getDatePeriod adding the $option parameterDateTime to DateTimeImmutable convertion improved for PHP 5.6+ versionDatePeriod constructor### Added - None ### Fixed - Period::contains see issue #28 ### Deprecated - None ### Removed - None
Period implements the JsonSerializable interface
Period implements the JsonSerializable interfacePeriod can now be extendedPeriod always returns DateTimeImmutable objectsPeriod::split returns a GeneratorPeriod::merge no longer throws RuntimeExceptionPeriod::getStartPeriod::getEndPeriod::getRangePeriod::durationPeriod::durationDiffPeriod always returns DateTime objects even when given DateTimeImmutable objects.
Period always returns DateTime objects even when given DateTimeImmutable objects.Period::split to split a Period object into smaller Period objects
Period::split to split a Period object into smaller Period objectsPeriod::getDatePeriodPeriod::getDateIntervalPeriod::getTimestampIntervalPeriod::getStartDatePeriod::getEndDatePeriod::dateIntervalDiffPeriod::timestampIntervalDiffDateInterval validation when created from an integer.Period::getStart you should use Period::getStartDate insteadPeriod::getEnd you should use Period::getEndDate insteadPeriod::getRange you should use Period::getDatePeriod insteadPeriod::duration you should use Period::getDateInterval or Period::getTimestampInterval insteadPeriod::durationDiff you should use Period::dateIntervalDiff or Period::timestampIntervalDiff insteadAdded support for DateTimeInterface interface
Period::diffDateTimeInterface interfacePeriod::createFromDurationBeforeEnd
Period::createFromDurationBeforeEndPeriod::isBefore Period::isAfter bug fixed. must take into account the half-open implementation of a Periodobject.Period::overlaps bug fixed issue #8
Period::gapPeriod::abutsPeriod::isAfterPeriod::isBeforePeriod::overlaps bug fixed issue #8Period::__toString using ISO8601 representation
Period::nextPeriod::previousPeriod::__toString using ISO8601 representationChange vendor namespace from Period to League\Period
Period to League\PeriodPeriod::sameValueAs,Period::compareDuration,Period::durationGreaterThan,Period::durationLessThan,Period::sameDurationAs,Period::durationDiffPeriod::add,Period::sub,Period::intersectPeriod::contains now works with Period objectsPeriod::getDuration accept an optional parameter $get_as_seconds if used and set to true, the method will return a integer which represents the duration in seconds.Period::merge now accepts one or more Period objects to return the Period object which contains all submitted Period objects.The $interval parameter can also an integer which represents the interval expressed in seconds.
$interval parameter can also an integer which represents the interval expressed in seconds.First stable release of Period
First stable release of Period
Added methods overlaps and merge
- bug fixes
Class name changed from ReportingPeriod to Period
Class name changed from ReportingPeriod to Period
contains, getRange, setDuration and getDurationyou can feed:
DateTime or a string when a DateTime is expectedDateInterval or a string when a DateInterval is expected[Next]: https://github.com/thephpleague/period/compare/5.2.1...master [5.2.1]: https://github.com/thephpleague/period/compare/5.2.0...5.2.1 [5.2.0]: h
Your coding agent can read these notes before it upgrades. Set up the MCP server →