shaked / time
PHP time package
Installs: 2 611
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:package
Requires
- php: >=7.0.0
Requires (Dev)
- phpunit/phpunit: 5.7.5
This package is not auto-updated.
Last update: 2025-07-01 20:57:29 UTC
README
The purpose of this package is to help developers to write a more readable PHP code while being able to easily test it.
The code is very much influenced by the Go time package.
Usage
@see TimeTest for more information.
<?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