granam / date-interval
Provides additional functionality to the DateInterval class
3.1.0
2021-03-25 07:56 UTC
Requires
- php: >=7.3
- ext-bcmath: *
Requires (Dev)
- phpunit/phpunit: ~9.0
- rector/rector: ^0.10.3
README
Provides additional functionality to the DateInterval class.
Usage
<?php use Granam\DateInterval\DateInterval; $interval = new DateInterval('P2H'); echo $interval->toSeconds(); // "7200" echo $interval->toSpec(); // "P2H" $fromSeconds = DateInterval::fromSeconds(7201); echo $fromSeconds->toSpec(); // P2HS1
Summary
The DateInterval
class builds on the existing DateInterval
class provided by PHP. With the new class, you may
- convert
DateInterval
to the interval spec - convert
DateInterval
to the number of seconds - convert number of seconds to
DateInterval
Installation
Add it to your list of Composer dependencies:
composer require granam/date-interval