DXNDateTime
in package
implements
DXNValueInterface
DXN `datetime` (`@datetime "2026-10-20T14:30:00Z"`) -- an instant with its offset, `Z` for UTC (DXN.md §1.3). DXN 0.2's `timestamp`, a UTC instant, is one of these at offset zero (Jan, 2026-10-20). Mirrors `.dxnb`'s wire shape directly: the instant as nanoseconds since the epoch, and the offset it was written with, in minutes.
$epochNanoseconds is a PHP integer, 64 bits: it reaches from 1677
to 2262, and an instant outside that is refused (Nanos).
DateTimeImmutable stops at the microsecond, so
self::toDateTimeImmutable() drops what is finer, and
self::fromDateTimeImmutable() is exact.
Table of Contents
Interfaces
- DXNValueInterface
- Implemented by every `DXN*` wrapper class -- the PHP analog of the `dxnType` string tag used for kind dispatch in the JS port, and of `Dextrin.Value`'s closed type union in the Elixir original. Native PHP values (`null`, `bool`, `int`, `float`, `string`, and `array` for `map`/`array`) never implement this; {@see Equality::kindOf()} handles those directly.
Constants
- DXN_TYPE : mixed = 'datetime'
Properties
- $epochNanoseconds : int
- $offsetMinutes : int
Methods
- __construct() : mixed
- compareTo() : int
- Ordered by instant, whatever the offsets.
- dxnType() : string
- The DXN type name this value represents, e.g. "symbol", "uuid".
- equals() : bool
- The same instant at the same offset: one written at another offset is another value.
- fromDateTimeImmutable() : self
- `$offsetMinutes` may be supplied explicitly -- `DateTimeImmutable` can't infer "the offset the caller means" any more than a plain instant can; it only knows the offset its own `DateTimeZone` carries, which this defaults to when not given.
- fromNative() : self
- A native date, as the `datetime` it always means (DXNS.md §7): its instant, with the offset its own zone carries at that instant.
- toDateTimeImmutable() : DateTimeImmutable
- The instant at its offset, to the microsecond.
Constants
DXN_TYPE
private
mixed
DXN_TYPE
= 'datetime'
Properties
$epochNanoseconds read-only
public
int
$epochNanoseconds
$offsetMinutes read-only
public
int
$offsetMinutes
Methods
__construct()
public
__construct(int $epochNanoseconds, int $offsetMinutes) : mixed
Parameters
- $epochNanoseconds : int
- $offsetMinutes : int
Tags
compareTo()
Ordered by instant, whatever the offsets.
public
compareTo(mixed $other) : int
Parameters
- $other : mixed
Return values
intdxnType()
The DXN type name this value represents, e.g. "symbol", "uuid".
public
dxnType() : string
Return values
stringequals()
The same instant at the same offset: one written at another offset is another value.
public
equals(mixed $other) : bool
Parameters
- $other : mixed
Return values
boolfromDateTimeImmutable()
`$offsetMinutes` may be supplied explicitly -- `DateTimeImmutable` can't infer "the offset the caller means" any more than a plain instant can; it only knows the offset its own `DateTimeZone` carries, which this defaults to when not given.
public
static fromDateTimeImmutable(DateTimeImmutable $date[, int|null $offsetMinutes = null ]) : self
Parameters
- $date : DateTimeImmutable
- $offsetMinutes : int|null = null
Tags
Return values
selffromNative()
A native date, as the `datetime` it always means (DXNS.md §7): its instant, with the offset its own zone carries at that instant.
public
static fromNative(DateTimeInterface $date) : self
A host value means the same DXN type with or without a schema, and
a native date always has a zone, which datetime keeps.
Parameters
- $date : DateTimeInterface
Tags
Return values
selftoDateTimeImmutable()
The instant at its offset, to the microsecond.
public
toDateTimeImmutable() : DateTimeImmutable