PHP code example of lubos / cakephp-interval

1. Go to this page and download the library: Download lubos/cakephp-interval library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lubos / cakephp-interval example snippets


$Interval = new \Interval\Interval\Interval();

// output 2w 6h
echo $Interval->toHuman((2 * 5 * 8 + 6) * 3600);

// output 36000
echo $Interval->toSeconds('1d 2h');

// in AppView
$this->loadHelper('Interval', ['className' => '\Interval\View\Helper\IntervalHelper']);

// in Template, output 2w 6h
<?= $this->Interval->toHuman((2 * 5 * 8 + 6) * 3600)