Docs
API Reference
DateTime

Datetime

ℹ️
Page is being worked on.

Functions

  1. now
  2. parse
  3. fromIsoDate
  4. fromUnixTimestamp
  5. fromUnixTimestampMillis
  6. fromLocalTime
  7. fromUniversalTime

Classes

  1. DateTime

Functions

now

datetime.now(): DateTime
Returns

parse

datetime.parse(date: string): DateTime
️⚠️
Can Error

Parse a string

  • Supports ISO8601 format, YYYY-MM-DDTHH:MM:SSZ
  • Supports RFC3339 format, YYYY-MM-DDTHH:MM:SS+00:00
  • Supports RFC2822 format, Day, DD Mon YYYY HH:MM:SS GMT
Parameters
  • date: string - The string to parse.
Returns
Throws
  • If the date is invalid, an error will be thrown.

fromIsoDate

datetime.fromIsoDate(date: string): DateTime
️⚠️
Can Error

Parse a string in ISO8601 format, YYYY-MM-DDTHH:MM:SSZ

Parameters
  • date: string - The string to parse.
Returns
Throws
  • If the date is invalid, an error will be thrown.

fromUnixTimestamp

datetime.fromUnixTimestamp(timestamp: number): DateTime
Parameters
  • timestamp: number - The timestamp to convert.
Returns
  • DateTime - The converted date and time.

fromUnixTimestampMillis

datetime.fromUnixTimestampMillis(timestamp: number): DateTime
Parameters
  • timestamp: number - The timestamp to convert.
Returns
  • DateTime - The converted date and time.

fromLocalTime

datetime.fromLocalTime(year: number, month: number, day: number, hour: number, minute: number, second: number, millisecond: number): DateTime
Parameters
  • year: number - The year.
  • month: number - The month.
  • day: number - The day.
  • hour: number - The hour.
  • minute: number - The minute.
  • second: number - The second.
  • millisecond: number - The millisecond.
Returns
  • DateTime - The converted date and time.

fromUniversalTime

datetime.fromUniversalTime(year: number, month: number, day: number, hour: number, minute: number, second: number, millisecond: number): DateTime
Parameters
  • year: number - The year.
  • month: number - The month.
  • day: number - The day.
  • hour: number - The hour.
  • minute: number - The minute.
  • second: number - The second.
  • millisecond: number - The millisecond.
Returns
  • DateTime - The converted date and time.

Classes

DateTime

Properties

  1. unixTimestamp | UnixTimestamp
  2. unixTimestampMillis | UnixTimestampMillis

Functions

  1. toLocalTime | ToLocalTime
  2. toUniversalTime | ToUniversalTime
  3. toIsoDate | ToIsoDate
  4. formatLocalTime | FormatLocalTime
  5. formatUniversalTime | FormatUniversalTime

DateTime.unixTimestamp

datetime.DateTime.unixTimestamp: number
datetime.DateTime.UnixTimestamp: number

DateTime.unixTimestampMillis

datetime.DateTime.unixTimestampMillis: number
datetime.DateTime.UnixTimestampMillis: number

DateTime.toLocalTime

datetime.DateTime:toLocalTime(): TimeDictionary
datetime.DateTime:ToLocalTime(): TimeDictionary
️⚠️
Can Error

Convert to local time and return a table

Returns
Throws
  • If datetime fails to convert, an error will be thrown.

DateTime.toUniversalTime

datetime.DateTime:toUniversalTime(): TimeDictionary
datetime.DateTime:ToUniversalTime(): TimeDictionary
️⚠️
Can Error

Convert to universal time and return a table

Returns
Throws
  • If datetime fails to convert, an error will be thrown.

DateTime.toIsoDate

datetime.DateTime:toIsoDate(): string
datetime.DateTime:ToIsoDate(): string

Convert to ISO8601 format, YYYY-MM-DDTHH:MM:SSZ

Returns
  • string - The converted date.

DateTime.formatLocalTime

datetime.DateTime:formatLocalTime(format: string): string
datetime.DateTime:FormatLocalTime(format: string): string
️⚠️
Can Error

Format the time in local time from a string

Parameters
  • format: string - The format to use.
Returns
  • string - The formatted time.
Throws
  • If datetime fails to convert, an error will be thrown.
  • If out of memory, an error will be thrown.

DateTime.formatUniversalTime

datetime.DateTime:formatUniversalTime(format: string): string
datetime.DateTime:FormatUniversalTime(format: string): string
️⚠️
Can Error

Format the time in universal time from a string

Parameters
  • format: string - The format to use.
Returns
  • string - The formatted time.
Throws
  • If datetime fails to convert, an error will be thrown.
  • If out of memory, an error will be thrown.

Types

TimeDictionary

export type TimeDictionary = {
    year : number,
    month : number,
    day : number,
    hour : number,
    minute : number,
    second : number,
    millisecond : number,
}