local function format_date(y, mo, d, h, mi, tz) local f = "%B %d %Y %I:%M%p " .. tz local tm = os.time({year = y, month = mo, day = d, hour = h, min = mi}) return os.date(f, tm):replace(" 0", " "):replace("AM", "am"):replace("PM", "pm") end local months = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" } local date = "March 7 2009 7:30pm EST" print($"Original date/time : {date}") local fields = date:split(" ") local fields2 = fields[4]:split(":") local mo = months:findindex(|m| -> fields[1] == m , 1, true) local d = tonumber(fields[2]) local y = tonumber(fields[3]) local h = tonumber(fields2[1]) local mi = tonumber(fields2[2]:sub(1, 2)) local ap = fields2[2]:sub(3, 4) local tz = fields[5] if ap == "pm" then h += 12 end if h == 12 or h == 24 then h -= 12 end -- Time and date 12 hours later local date2 = format_date(y, mo, d, h + 12, mi, tz) print($"12 hours later : {date2}") -- Switch to MST time zone which is 2 hours earlier than EST. local date3 = format_date(y, mo, d, h + 10, mi, "MST") print($"Adjusted to MST : {date3}")