Download the PHP package gamez/duration without Composer
On this page you can find all versions of the php package gamez/duration. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gamez/duration
More information about gamez/duration
Files in gamez/duration
Package duration
Short Description Working with durations made easy
License MIT
Homepage https://github.com/jeromegamez/duration-php
Informations about the package duration
Duration for PHP
Working with durations made easy.
Do you like to use DateInterval to compute and work with durations? Me neither, so let's fix that!
- Installation
- Reference
- Supported Input Values
- Weeks, months, and years
- Transformations
- Comparisons
- Operations
- Roadmap
Installation
You can install the package with Composer:
You can then use Duration:
Reference
Supported input values
DateIntervals
Colon notation
Textual notation
A textual notation is any value that can be processed by DateInterval::createFromDateString()
Weeks, months, and years
Weeks are normalized to seven days, so P1W is represented as P7D.
Months and years do not have a fixed length. When Duration compares, adds, subtracts, multiplies, divides, or
normalizes such values, it evaluates them relative to a cached UTC date and time. This avoids daylight-saving
transitions, but results can still depend on the calendar date. For example, one month can span 28 to 31 days and one
year can span 365 or 366 days.
If exact elapsed time matters, prefer days, hours, minutes, and seconds. Use months and years only when calendar-relative behavior is intended.
Transformations
When transformed, a Duration will be
- converted to a DateInterval representation
- optimized in the sense that an input value of 60 seconds would result in an output value of "1 minute", for example "PT60S" would be converted to "PT1H"
Comparisons
Operations
Results will always be rounded by the second.
Roadmap
- Support more input formats
- Add "output for humans" (like colon notation)
- Support precision (similar to spatie/period)
- ...
All versions of duration with dependencies
ext-ctype Version *