Skip to content

DateTime

An Object representing a date and time.

local chrono = require("@vara/chrono")

local timestamp = chrono.FromUniversal({
    Year = 2025,
    Month = 9,
    Day = 10,

    Hour = 18,
    Minute = 20,
    Second = 0,
    Millisecond = 0,
})

print(timestamp:Humanise())

properties

TimeOffset : number

The UTC offset in hours.

Year : number

The ammount of years.

Month : number

The ammount of months.

Day : number

The ammount of Days.

Hour : number

The ammount of Hours.

Minute : number

The ammount of Minutes.

Second : number

The ammount of Seconds.

Millisecond : number

The ammount of Milliseconds.


methods

ToISO8601 -> string

DateTime:ToISO8601() : string

Formats the datetime according to the ISO8601 standard.

ToRFC2822 -> string

DateTime:ToRFC2822() : string

Formats the datetime according to the RFC2822 standard.

Humanise -> string

DateTime:Humanise() : string

Formats the datetime so thats its human readable.

ToZH -> string

DateTime:ToZH() : string

Formats the datetime so that its human readable in mandarin.

toApacheLog -> string

DateTime:ToApacheLog() : string

Formats the datetime as an Apache Log timestamp.


metamethods

__tostring -> string

Converts the data to a string, formatted according to ToISO8601.

__eq -> boolean

Checks if 2 datetimes are equivalent.

__le -> boolean

Checks if the datetime is earlier than or equivalent to another datetime.

__lt -> boolean

Checks if the datetime is earlier than another datetime.