tubssp / date-interval
Provides additional functionality to the DateInterval class.
Installs: 119
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 7
Open Issues: 0
pkg:composer/tubssp/date-interval
Requires
- php: >=5.3
- ext-bcmath: *
Requires (Dev)
- phpunit/phpunit: 3.7.*|~4|~5
This package is not auto-updated.
Last update: 2016-02-04 08:33:22 UTC
README
Provides additional functionality to the DateInterval class.
Summary
The DateInterval class builds on the existing DateInterval class provided by PHP. With the new class, you may
- convert
DateIntervalto the interval spec - convert
DateIntervalto the number of seconds- convert back to
DateIntervalfrom the number of seconds
- convert back to
The conversion to seconds requires a bit of explaining.
Installation
Add it to your list of Composer dependencies:
$ composer require herrera-io/date-interval=1.*
Usage
<?php
use Herrera\DateInterval\DateInterval;
$interval = new DateInteval('P2H');
echo $interval->toSeconds(); // "7200"
echo DateInterval::toSeconds($interval); // "7200"
echo $interval->toSpec(); // "P2H"
echo DateInterval::toSpec($interval); // "P2H"