, Lua DateTime; Lua , . , Lua, .
, os.date, , Unix time ( 1 1970 .). , Unix-, os.time. , os.time , .
, , , os.date os.time. , @tonypdmtr string.gsub . - , string.match string.format:
local date = '05/17/2017 05:17:00 PM'
local month, day, year, hours, minutes, seconds, amPm = date:match('^(%d%d)/(%d%d)/(%d%d%d%d) (%d%d):(%d%d):(%d%d) ([AP]M)$')
if not month then
error('could not parse date "' .. date .. '"')
end
if amPm == 'PM' then
hours = string.format('%2d', tonumber(hours) + 12)
end
local newDate = string.format(
'%s-%s-%s %s:%s:%s',
year, month, day, hours, minutes, seconds
)
print(newDate)