1. Go to this page and download the library: Download tobento/service-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/ */
tobento / service-clock example snippets
use Tobento\Service\Clock\SystemClock;
use Psr\Clock\ClockInterface;
$clock = new SystemClock();
var_dump($clock instanceof ClockInterface);
// bool(true)
use Tobento\Service\Clock\SystemClock;
use DateTimeZone;
$clock = new SystemClock(
timezone: 'UTC'
);
$clock = new SystemClock(
timezone: new DateTimeZone('Europe/Berlin')
);
use Tobento\Service\Clock\FrozenClock;
use Psr\Clock\ClockInterface;
$clock = new FrozenClock();
var_dump($clock instanceof ClockInterface);
// bool(true)
// Modify the clock returning a new instance.
// Will accept all formats supported by DateTimeImmutable::modify()
$clockNew = $clock->modify('+30 seconds');
// With a new timezone returning a new instance.
$clockNew = $clock->withTimeZone(timezone: 'UTC');
use Tobento\Service\Clock\FrozenClock;
use Tobento\Service\Clock\SystemClock;
use Psr\Clock\ClockInterface;
use DateTimeImmutable;
$clock = new FrozenClock(
now: new DateTimeImmutable()
);
// or from another clock:
$clock = new FrozenClock(
now: new SystemClock()
);
timezone
date_default_timezone_get
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.