PHP code example of ergebnis / clock

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

    

ergebnis / clock example snippets




declare(strict_types=1);

use Ergebnis\Clock;

$clock = new Clock\SystemClock(new \DateTimeZone('Europe/Berlin'));

$now = $clock->now();



declare(strict_types=1);

use Ergebnis\Clock;

$clock = new Clock\SystemClock(new \DateTimeZone('Europe/Berlin'));

$frozenClock = $clock->freeze();

$now = $clock->now();

sleep(5);

$stillNow = $clock->now();



declare(strict_types=1);

use Ergebnis\Clock;

$clock = new Clock\UtcClock();

$now = $clock->now();



declare(strict_types=1);

use Ergebnis\Clock;

$clock = new Clock\UtcClock();

$frozenClock = $clock->freeze();

$now = $clock->now();

sleep(5);

$stillNow = $clock->now();



declare(strict_types=1);

use Ergebnis\Clock;

$now = new \DateTimeImmutable();

$clock = new Clock\FrozenClock($now);

sleep(5);

$stillNow = $clock->now();