PHP code example of ordinary / clock
1. Go to this page and download the library: Download ordinary/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/ */
ordinary / clock example snippets
use Ordinary\Clock\ClockInterface;
use Ordinary\Clock\UTCClock;
class MyTimeAwareAction
{
public function __construct(protected ClockInterface $clock)
{
}
public function announceTime(): void
{
echo 'Time is now ' . $this->clock->now()->format('c') . PHP_EOL;
}
}
$action = new MyTimeAwareAction(new UTCClock());
$action->announceTime();
$clock = new UTCClock();
$clock = new AlternateTimeZoneClock($primaryClock = new UTCClock(), new DateTimeZone('America/Chicago'))
$clock = new \Ordinary\Clock\SystemClock(new DateTimeZone('America/Chicago'));