PHP code example of ebene7 / php-clock

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

    

ebene7 / php-clock example snippets




use E7\Clock\SystemClock;

$clock = new SystemClock();
$now = $clock->now();




use DateTimeZone;
use E7\Clock\SystemClock;

$timezone = new DateTimeZone('Europe/Berlin');
$clock = new SystemClock(timezone);
$now = $clock->now();



use DateTimeImmutable;
use E7\Clock\FrozenClock;

$now = new DateTimeImmutable();
$clock = new FrozenClock($now);
$now = $clock->now();