You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
composer require lubos/cakephp-interval
Load plugin in bootstrap.php file
bin/cake plugin load Interval
In human readable string, following can be used
w = week
d = day
h = hour
m = minute
s = second
$Interval = new \Interval\Interval\Interval();
// output 2w 6h
echo $Interval->toHuman((2 * 5 * 8 + 6) * 3600);
// output 36000
echo $Interval->toSeconds('1d 2h');
You can use ./src/Traits/IntervalTrait.php
or cakephp component / helper.
Helper example
// in AppView
$this->loadHelper('Interval', ['className' => '\Interval\View\Helper\IntervalHelper']);
// in Template, output 2w 6h
<?= $this->Interval->toHuman((2 * 5 * 8 + 6) * 3600) ?>
See ./tests/TestCase/Interval/IntervalTest.php for more examples
For bugs and feature requests, please use the issues section of this repository.
If you want to help, pull requests are welcome.
Please follow few rules:
- Fork & clone
- Code bugfix or feature
- Follow CakePHP coding standards
- Unit tests