DateTime
A UTC instant represented as Unix nanoseconds.
Type Methods
now()
Returns the current UTC time.
from_unix seconds? :nanos?
Creates a DateTime from a Unix timestamp.
Parameters
| Name | Type | Description |
|---|---|---|
seconds |
Int|Float? |
Optional seconds since Unix epoch |
nanos |
Int? |
Optional nanoseconds since Unix epoch or offset to add |
echo $ DateTime.from_unix 1700000000
echo $ DateTime.from_unix 1.25
echo $ DateTime.from_unix nanos: 1700000000123000000
echo $ DateTime.from_unix 1700000000 nanos: 123000000
parse_rfc3339 text
Parses an RFC3339 timestamp.
Parameters
| Name | Type | Description |
|---|---|---|
text |
Str |
RFC3339 input text |
Returns
Errors
| Exception | Condition |
|---|---|
ValueError |
The input is not a valid RFC3339 timestamp |
Fields
| Field | Type | Description |
|---|---|---|
unix_secs |
Float |
Approximate Unix seconds view |
unix_nanos |
Int |
Exact Unix nanoseconds view |
Operators
DateTime - DateTime -> Duration
Methods
rfc3339()
Returns the RFC3339 representation.
Returns
String Form
str(datetime) renders the same UTC RFC3339 timestamp as datetime.rfc3339().