1. Go to this page and download the library: Download sanmai/duoclock 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/ */
sanmai / duoclock example snippets
namespace DuoClock;
interface DuoClockInterface
{
public function time(): int;
public function microtime(): float;
}
interface SleeperInterface
{
public function sleep(int $seconds): int;
public function usleep(int $microseconds): void;
}
$clock = new DuoClock\DuoClock();
$clock->now(); // DateTimeImmutable
$clock->time(); // int
$clock->microtime(); // float
$clock->sleep(1); // real sleep
$clock->usleep(1000); // real micro-sleep
$clock = new DuoClock\TimeSpy(1752321600); // Corresponds to '2025-07-12T12:00:00Z'
$clock->time(); // 1752321600
$clock->sleep(10); // advances virtual clock by 10 seconds
$clock->usleep(5000); // advances virtual clock by 0.005 seconds
$clock->time(); // 1752321610
$clock->microtime(); // 1752321610.005