PHP code example of rasuvaeff / duration

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

    

rasuvaeff / duration example snippets

 doc-exec
use Rasuvaeff\Duration\Duration;

$timeout = Duration::seconds(2.5);

$timeout->toMillis();  // => 2500
$timeout->toMicros();  // => 2500000
$timeout->toSeconds(); // => 2.5

$total = Duration::millis(500)->plus(Duration::seconds(1));
$total->toMillis(); // => 1500

Duration::seconds(1)->isGreaterThan(Duration::millis(500)); // => true

echo Duration::minutes(1.5); // outputs 1.5min