DateTime
Represents an instant with Unix timestamp and calendar conversions.
Behavior
DateTime represents an instant with Unix timestamp and calendar conversions.
Summary
Parses an ISO date string.
DateTime.fromLocalTime(year: number?, month: number?, day: number?, hour: number?, minute: number?, second: number?, millisecond: number?): DateTimeCreates a DateTime from local calendar fields.
DateTime.fromUniversalTime(year: number?, month: number?, day: number?, hour: number?, minute: number?, second: number?, millisecond: number?): DateTimeCreates a DateTime from UTC calendar fields.
Creates a DateTime from seconds since the Unix epoch.
Creates a DateTime from milliseconds since the Unix epoch.
Returns the current date and time.
The time in seconds since the Unix epoch.
The time in milliseconds since the Unix epoch.
Format(pattern: string): stringFormats the date and time using the supplied pattern.
ToIsoDate(): stringReturns the date and time as an ISO-formatted string.
ToLocalTime(): tableReturns local calendar fields as a table.
ToUniversalIsoDate(): stringReturns the date and time as a UTC ISO-formatted string.
ToUniversalTime(): tableReturns UTC calendar fields as a table.
Constructors
fromIsoDate
DateTime.fromIsoDate(isoDate: string): DateTime?Parses an ISO date string. Returns nil when the input cannot be parsed.
fromLocalTime
DateTime.fromLocalTime(year: number?, month: number?, day: number?, hour: number?, minute: number?, second: number?, millisecond: number?): DateTimeCreates a DateTime from local calendar fields.
fromUniversalTime
DateTime.fromUniversalTime(year: number?, month: number?, day: number?, hour: number?, minute: number?, second: number?, millisecond: number?): DateTimeCreates a DateTime from UTC calendar fields.
fromUnixTimestamp
DateTime.fromUnixTimestamp(unixTimestamp: number): DateTimeCreates a DateTime from seconds since the Unix epoch.
fromUnixTimestampMillis
DateTime.fromUnixTimestampMillis(unixTimestampMillis: number): DateTimeCreates a DateTime from milliseconds since the Unix epoch.
now
DateTime.now(): DateTimeReturns the current date and time.
Properties
UnixTimestamp
DateTime.UnixTimestamp: numberThe time in seconds since the Unix epoch.
UnixTimestampMillis
DateTime.UnixTimestampMillis: numberThe time in milliseconds since the Unix epoch.
Methods
Format
DateTime:Format(pattern: string): stringFormats the date and time using the supplied pattern.
ToIsoDate
DateTime:ToIsoDate(): stringReturns the date and time as an ISO-formatted string.
ToLocalTime
DateTime:ToLocalTime(): tableReturns local calendar fields as a table.
ToUniversalIsoDate
DateTime:ToUniversalIsoDate(): stringReturns the date and time as a UTC ISO-formatted string.
ToUniversalTime
DateTime:ToUniversalTime(): tableReturns UTC calendar fields as a table.
Operators
__eq · __le · __lt · __tostring · __type