Centum\Clock

The Clock component handles time determination.

Centum\Clock\Clock(
    string $datetime = "now",
    ?DateTimeZone $timezone = null
);
use Centum\Clock\Clock;

$clock = new Clock();

Centum\Clock\Clock implements Centum\Interfaces\Clock\ClockInterface.

The now() method returns a DateTimeImmutable instance that can be used for when your code needs to reference the current time.

$now = $clock->now();

$model->setDateUpdated($now);

This can be useful in testing that has timing-based side effects to ensure that tests are consistent and repeatable.


Table of contents