Skip to content

LubosRemplik/CakePHP-Interval

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

About

Interval plugin for CakePHP

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages