RequestClock implements ClockInterface
FinalYes
PSR-20 clock that is frozen at the start of the current request and returns the same instant on every call.
Inject this concrete class when multiple reads within one request must yield a consistent "time of the current request" - the same semantics as reading $GLOBALS['EXEC_TIME']. For the actual, advancing wall-clock time (e.g. expiry checks, long-running CLI processes), inject ClockInterface to receive the SystemClock instead.
Table of Contents
Interfaces
- ClockInterface
Methods
- __construct() : mixed
- create() : self
- Creates a clock frozen at the timestamp the current PHP process started to handle the request. The instance is provided to the dependency injection container during boot.
- now() : DateTimeImmutable
Methods
__construct()
public
__construct([DateTimeImmutable|null $frozenAt = null ]) : mixed
Parameters
- $frozenAt : DateTimeImmutable|null = null
create()
Creates a clock frozen at the timestamp the current PHP process started to handle the request. The instance is provided to the dependency injection container during boot.
public
static create() : self
bridges the request start time currently taken during low-level system environment setup, only to be used during TYPO3 bootstrap
Return values
selfnow()
public
now() : DateTimeImmutable