Skip to main content

Formatted Date String to Timestamp (utils.date_from_format)

Declaration

timestamp = utils.date_from_format(format, date[, options])

Parameters

  • format
    String. Date format.
  • date
    String. Date string.
  • options
    Table. Options.
    {
    tz = "GMT"; -- Timezone. Optional. Default: system timezone. See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
    locale = "en-US"; -- Locale. Optional. Default: root user's locale
    }

Returns

  • timestamp
    Number. Unix timestamp.

Notes

Available after 2025-02-20.

Format Reference

Unicode Date Field Symbol Table

CategoryTokenExampleDescription
Yearyyyy20244-digit year
yy242-digit year
MonthMMMMJulyFull month name
MMMJulAbbreviated month
MM072-digit month (01-12)
M71-2 digit month
Daydd062-digit day (01-31)
d61-2 digit day
Day of WeekEEEESaturdayFull name
E, EE, EEESatAbbreviation
e, ee7Localized weekday number (Sun=1, Sat=7)
HourHH1524h two-digit (00-23)
H1524h 1-2 digit
hh0312h two-digit (01-12)
h312h 1-2 digit
aPMAM/PM
Minutemm05Two-digit minute (00-59)
m51-2 digit minute
Secondss09Two-digit second (00-59)
S.1 .12 .123Milliseconds; count of S sets decimals
Time ZonezzzzPacific Daylight TimeFull name
zzz, zPDTAbbreviation
ZZZZZ-07:00ISO 8601 offset with colon
Z, ZZ, ZZZ-0700RFC 822 offset

Examples

nLog(utils.date_from_format("EEE, dd MMM yyyy HH:mm:ss ZZZZ", "Mon, 09 Jun 2025 17:40:00 GMT", {tz = "GMT"; locale = 'en-US'})) -- 1749490800.0