Skip to main content

Timestamp to Formatted Date String (utils.date_to_format)

Declaration

date = utils.date_to_format(format, timestamp)

Parameters

  • format
    String. Date format.
  • timestamp
    Number. Unix timestamp.
  • 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

  • date
    String. Formatted date string.

Notes

Available after 2025-02-20.

Format Reference

See: Unicode Date Field Symbol Table

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

Examples

nLog(utils.date_to_format("EEE, dd MMM yyyy HH:mm:ss ZZZZ", 1749490800, {tz = "PST"; locale = 'en-US'}))
nLog(utils.date_to_format("EEE, dd MMM yyyy HH:mm:ss ZZZZ", 1749490800, {tz = "PST"; locale = 'zh-CN'}))