CooperLocalDateTime
in package
implements
Stringable, JsonSerializable
A CASC local date-time (CASC.md ยง6.6) -- `1979-05-27T07:32:00` with no offset -- matching Elixir's `NaiveDateTime`. An *offset* date-time (`...Z`, `...+02:00`) is a real instant and loads as a `CooperDateTime` instead; this one names a wall-clock reading in no particular zone, which `toDateTimeImmutable()` lets the caller place.
Table of Contents
Interfaces
- Stringable
- JsonSerializable
Properties
Methods
- __construct() : mixed
- __toString() : string
- Space-separated, as Elixir's `NaiveDateTime` prints -- the form an interpolated `"@{when}"` produces in every Cooper implementation.
- equals() : bool
- jsonSerialize() : string
- Encodes as the ISO 8601 form (`toIso8601()`).
- toDateTimeImmutable() : DateTimeImmutable
- This wall-clock reading, in `$timezone` (default: PHP's default zone).
- toIso8601() : string
Properties
$date read-only
public
CooperDate
$date
$time read-only
public
CooperTime
$time
Methods
__construct()
public
__construct(CooperDate $date, CooperTime $time) : mixed
Parameters
- $date : CooperDate
-
the calendar date
- $time : CooperTime
-
the time of day
__toString()
Space-separated, as Elixir's `NaiveDateTime` prints -- the form an interpolated `"@{when}"` produces in every Cooper implementation.
public
__toString() : string
Use toIso8601() for the T-separated form.
Return values
string —YYYY-MM-DD HH:MM:SS[.fff]
equals()
public
equals(mixed $other) : bool
Parameters
- $other : mixed
-
the value to compare against
Return values
bool —true for the same date and time
jsonSerialize()
Encodes as the ISO 8601 form (`toIso8601()`).
public
jsonSerialize() : string
Return values
string —the T-separated form
toDateTimeImmutable()
This wall-clock reading, in `$timezone` (default: PHP's default zone).
public
toDateTimeImmutable([DateTimeZone|null $timezone = null ]) : DateTimeImmutable
Parameters
- $timezone : DateTimeZone|null = null
-
the zone to interpret the reading in
Return values
DateTimeImmutable —the corresponding instant
toIso8601()
public
toIso8601() : string
Return values
string —the ISO 8601 form, YYYY-MM-DDTHH:MM:SS[.fff]