function setepoch (s)
local y,m,d
y,m,d = string.match(s,"^(%d%d%d%d)-(%d%d)-(%d%d)$")
if y then
return os.time{year=y, month=m, day=d, hour=0,sec=0,isdst=nil} -
os.time{year=1970, month=1, day=1, hour=0,sec=0,isdst=nil}
else if string.match(s,"^%d+$") then
return tonumber(s)
else
return 0
end
end
end
print ('A: ' .. setepoch('112233')) -- arbitrary number
print ('B: ' .. setepoch('1970-01-01')) -- date (the start of time)
print ('C: ' .. setepoch('2017-06-29')) -- today