Simple implementation of PSR-20 (Clock).
The following versions of PHP are supported by this version.
- PHP ^8.1
All clocks are implementing the Psr\Clock\ClockInterface.
The SystemClock just gives the current time according to your system.
use Jd297\Psr\Clock\SystemClock;
$clock = new SystemClock();
$unixTimestamp = $clock->now()->getTimestamp();
The StaticClock is suitable for mocking your application.
use Jd297\Psr\Clock\StaticClock;
$clock = new StaticClock('2001-09-09 01:46:40.000000');
$unixTimestamp = $clock->now()->getTimestamp(); // 1000000000
Reformat code with PHP CS Fixer.
$ composer reformat
Test source code with PHPUnit.
$ composer unit
Analyse files with PHPStan (Level 9).
$ composer analyse
The BSD 2-Clause "Simplified" License (BSD-2-Clause). Please see License File for more information.