package time
PHP time package
shaked/time
PHP time package
- Tuesday, January 16, 2018
- by shaked
- Repository
- 1 Watchers
- 0 Stars
- 1,135 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 2 Versions
- 11 % Grown
PHP time package
, (*1)
The purpose of this package is to help developers to write a more readable PHP code while being able to easily test it., (*2)
The code is very much influenced by the Go time package., (*3)
Usage
@see TimeTest for more information., (*4)
<?php
require_once 'vendor/autoload.php';
use shaked\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