Clock
in package
implements
ClockInterface
FinalYes
A global clock.
Tags
Table of Contents
Interfaces
Properties
- $clock : ClockInterface|null
- $globalClock : ClockInterface
- $timezone : DateTimeZone|null
Methods
- __construct() : mixed
- get() : ClockInterface
- Returns the current global clock.
- now() : DatePoint
- Returns the current time as a DateTimeImmutable Object
- set() : void
- sleep() : void
- withTimeZone() : static
Properties
$clock read-only
private
ClockInterface|null
$clock
= null
$globalClock
private
static ClockInterface
$globalClock
$timezone
private
DateTimeZone|null
$timezone
= null
Methods
__construct()
public
__construct([ClockInterface|null $clock = null ][, DateTimeZone|null $timezone = null ]) : mixed
Parameters
- $clock : ClockInterface|null = null
- $timezone : DateTimeZone|null = null
get()
Returns the current global clock.
public
static get() : ClockInterface
Note that you should prefer injecting a ClockInterface or using ClockAwareTrait when possible instead of using this method.
Return values
ClockInterfacenow()
Returns the current time as a DateTimeImmutable Object
public
now() : DatePoint
Return values
DatePointset()
public
static set(ClockInterface $clock) : void
Parameters
- $clock : ClockInterface
sleep()
public
sleep(float|int $seconds) : void
Parameters
- $seconds : float|int
withTimeZone()
public
withTimeZone(DateTimeZone|string $timezone) : static
Parameters
- $timezone : DateTimeZone|string