Clock class abstract final

The framework's source of "now" (BLUEPRINT_V2 §7.11).

Domain time — model timestamps, token and JWT expiry, cache TTLs, rate limit windows, delayed jobs, schedules, signed URLs — reads Clock.now, so tests can freeze or travel through time (Laravel travel() / Carbon::setTestNow()). Wall-clock concerns (timeouts, polling deadlines, log timestamps) keep using DateTime.now().

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Properties

isFaked → bool
Whether time is currently faked.
no setter

Static Methods

at<T>(DateTime time, Future<T> body()) → Future<T>
Runs body with time frozen at time, restoring afterwards.
fake([DateTime? time]) → DateTime
Freezes time at time (default: now).
freeze() → DateTime
Freezes time at the current instant ($this->freezeTime()).
isTimeZone(String zone) → bool
Whether zone is an IANA name.
now() → DateTime
The current time (frozen when faked).
nowIn(String zone) → DateTime
Laravel's now('Asia/Makassar'): the current time in the IANA zone, frozen with now in tests. Its hour and friends read the wall clock there; it compares and serializes as the same instant.
nowUtc() → DateTime
The current time in UTC.
restore() → void
Returns to real time ($this->travelBack()).
timeZone(String zone) → Location
The IANA zone; an ArgumentError for an unknown name.
travel(Duration duration) → DateTime
Moves (frozen) time forward by duration; negative values go back.
travelTo(DateTime time) → DateTime
Jumps to time and freezes there ($this->travelTo()).