Skip to content

Shaked/time

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP time package

Build Status

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