PHP code example of eventsauce / clock

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

    

eventsauce / clock example snippets




use EventSauce\Clock\SystemClock;

$clock = new SystemClock(new DateTimeZone('UTC') /* timezone optional */);

$dateTimeImmutable = $clock->now();
$timezone = $clock->timeZone();



use EventSauce\Clock\TestClock;

$testClock = new TestClock();
$dateTimeImmutable = $testClock->now();
$timezone = $testClock->timeZone();

// move the clock forward
$testClock->moveForward(DateInterval::createFromDateString('1 day'));

// Skip to system "now"
$testClock->tick();

// Fixate the clock to a specific date and time
$testClock->fixate('1987-11-24 18:33:10');