local timestamp = os.time() local dt1 = os.date( "!*t", timestamp ) -- UTC local dt2 = os.date( "*t" , timestamp ) -- local
日期转时间戳
os.date("%Y%m%d%H",unixtime)
时间戳转日期
os.time({day=17, month=8, year=2018, hour=0, minute=0, second=0})
当前时间
os.time()
获取Utc时间戳
function getTimeZone()
local now = os.time()
return os.difftime(now, os.time(os.date("!*t", now)))
end
local serverTime = os.time() --
-- 8 hour * 3600 seconds = 28800 seconds
local timeZone = getTimeZone()/ 3600
local timeInterval = os.time(os.date("!*t", serverTime)) + (os.date("*t", time).isdst and -1 or 0) * 3600
isdst 冬令时 夏令时区分