PHP code example of shaked / time

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

    

shaked / time example snippets




haked\time\Duration;

$n = 60;

$durations = [
    'nanosecond'  => Duration::nanosecond($n),
    'microsecond' => Duration::microsecond($n),
    'millisecond' => Duration::millisecond($n),
    'second'      => Duration::second($n),
    'minute'      => Duration::minute($n),
    'hour'        => Duration::hour($n),
];

foreach ($durations as $duration) {
    (new Sleep())->for($duration);
    echo (string) $duration . PHP_EOL;
}

// 60ns
// 60µs
// 60ms
// 1m0s
// 1h0m0s
// 60h0m0s