Documentation

Clock
in package
implements ClockInterface

FinalYes

A global clock.

Tags
author

Nicolas Grekas p@tchwork.com

Table of Contents

Interfaces

ClockInterface

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

$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
ClockInterface

sleep()

public sleep(float|int $seconds) : void
Parameters
$seconds : float|int

withTimeZone()

public withTimeZone(DateTimeZone|string $timezone) : static
Parameters
$timezone : DateTimeZone|string
Tags
throws
DateInvalidTimeZoneException

When $timezone is invalid

Return values
static

        
On this page

Search results