/CakePHP-Interval

Interval plugin for CakePHP

Primary LanguagePHP

Interval plugin for CakePHP

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

Installation

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

Usage

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

Bugs & Features

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: