PHP code example of pekkis / clock

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

    

pekkis / clock example snippets




namespace Pekkis\Clock\Example;

kkis\Clock\FixedClock;
use DateTime;

// Real system clock, returns actual time
$time = ClockProvider::getClock()->getTime();
var_dump($time);

// Fixed clock (for testing for example)
ClockProvider::setClock(new FixedClock(new DateTime('1978-03-21')));
$time = ClockProvider::getClock()->getTime();
var_dump($time);

// Get time as datetime object
$time = ClockProvider::getClock()->getDateTime();
var_dump($time->format('Y-m-d H:i:s'));