PSR-20 Implementation

2.5.0 2023-11-15 19:44 UTC

This package is auto-updated.

Last update: 2024-05-07 23:53:11 UTC


Packagist PHP License Gitlab pipeline status Codecov Downloads

A collection of clock abstraction classes for PSR-20.


composer require arokettu/clock

Supported versions:

  • 1.x (LTS-ish, PHP 7.0+)
  • 2.x (current, PHP 8.0+)



$clock = new \Arokettu\Clock\SystemClock();

For a specific example, lcobucci/jwt:


use Arokettu\Clock\SystemClock;
use Lcobucci\JWT\Configuration;
use Lcobucci\JWT\Signer\Hmac\Sha256;

$cfg = Configuration::forSymmetricSigner(new Sha256(), '...');
$token = $cfg->parser()->parse('...');

    new StrictValidAt(new SystemClock())


Available clock classes:

  • SystemClock. Plain class that returns operating system clock, also available as a separate package: arokettu/system-clock
  • ShiftedClock. System clock + fixed interval
  • StaticClock. Clock that returns a single set value
  • MutableClock. Based on mutable DateTime class
  • TickingClock. Clock that advances an interval every call
  • CallbackClock. A wrapper for a closure that also supports generator closures
  • RoundingClock. A clock wrapper that rounds time to a certain precision

Read full documentation here:

Also on Read the Docs:


Please file issues on our main repo at GitLab:

Feel free to ask any questions in our room on Gitter:


The library is available as open source under the terms of the MIT License.