PHP code example of kreait / clock

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

    

kreait / clock example snippets




reait\Clock\FrozenClock;
use Kreait\Clock\SystemClock;

$systemClock = new SystemClock(new DateTimeZone('UTC'));
var_dump($systemClock->now());

$frozenClock = new FrozenClock(new DateTimeImmutable('2019-08-20 10:41:53'));
var_dump($frozenClock->now());

$frozenClock->setTo(new DateTimeImmutable('2019-08-19 19:19:19'));
var_dump($frozenClock->now());