PHP code example of wallacemaxters / timer

1. Go to this page and download the library: Download wallacemaxters/timer 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/ */

    

wallacemaxters / timer example snippets


use WallaceMaxters\Timer\Time;

$time = Time::create(0, 0, 10);

$time->format('%h:%i%s'); // '00:00:10'

$time->addSeconds(30);

$time->format(); // '00:00:40'

$time->addSeconds(-50);

$time->format('%h:%i%s'); // '-00:00:10'



use WallaceMaxters\Timer\Collection;

$collection = new Collection;

$collection[] = Time::create(0, 10, 0);

$collection[] = Time::createFromString('10 seconds');

$collection[] = Time::createFromFormat('%h:%i', '00:50');

$collection->sum(); // new Time(0, 11, 0);

$collection->min(); // new time(0, 0, 10); 


// DateTime
$date = DateTime::createFromFormat('25:00:00');

var_dump($date->format('H:i:s')); // 01:00:00

// WallaceMaxters\Timer\Timer

$time = Time::createFromFormat('%h:%i:%s', '26:00:00');

var_dump($time->format()); // '26:00:00'