-- Фиксированный момент: вывод не меняется
local moment = 1798841600
-- "!" - UTC, %I - 12-часовые часы, %p - AM/PM
local short_style =
os.date("!%m/%d/%y %I:%M %p", moment)
-- short_style = 01/01/27 10:13 PM
local custom_style = os.date("!%Y-%m-%d", moment)
-- custom_style = 2027-01-01
-- %F - то же, что %Y-%m-%d, %T - то же, что %H:%M:%S
local standard_style = os.date("!%F %T", moment)
-- standard_style = 2027-01-01 22:13:20
-- ISO 8601: "T" между датой и временем
local iso_style = os.date("!%FT%T", moment)
-- iso_style = 2027-01-01T22:13:20
-- %c - стиль, который используется без формата
local default_style = os.date("!%c", moment)
-- default_style = Fri Jan 1 22:13:20 2027
-- Внутри предложения те же коды
local str_format =
"Today " .. os.date("!%d %B", moment)
-- str_format = Today 01 January
print("short_style = " .. short_style)
print("custom_style = " .. custom_style)
print("standard_style = " .. standard_style)
print("iso_style = " .. iso_style)
print("default_style = " .. default_style)
print("str_format = " .. str_format)
-- Неизвестный код - ошибка
local ok, err = pcall(os.date, "%Q", moment)
-- ok = false
-- err = bad argument #1 to 'os.date' (invalid
-- conversion specifier '%Q')
print("ok = " .. tostring(ok))
print("err = " .. err)