lua 获取时间

local currTime = os.time() -- 当前时间戳
local checkTime = os.time({ day = 12, month = 1, year = 2021, hour = 00, min = 00, sec = 00 }) -- 指定时间的时间戳

--时间判断
if currTime < checkTime then
  print("1")
else
  print("2")
end

--时间戳转日期
function getTimeStamp(t)
  return os.date("%Y-%m-%d %H:%M:%S",t)
end

--当前时间
local dates=os.date("%Y-%m-%d %H:%M:%S")
print(dates)

--时间戳转日期
print(getTimeStamp(checkTime) )

  

posted @ 2021-05-12 14:23  酉乐  阅读(892)  评论(0编辑  收藏  举报