源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

Lua时间转化的几个小例子

  • 时间:2022-08-18 04:27 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:Lua时间转化的几个小例子
1、把时间 秒,转化为xx天xx时xx分xx秒 的形式
[u]复制代码[/u] 代码如下:
--把时间 秒,转化为xx天xx时xx分xx秒 的形式 function convertTimeForm(second)     local timeDay                   = math.floor(second/86400)     local timeHour                  = math.fmod(math.floor(second/3600), 24)     local timeMinute                = math.fmod(math.floor(second/60), 60)     local timeSecond                = math.fmod(second, 60)     return timeDay, timeHour, timeMinute, timeSecond end
2、把时间 秒,转化为xx时xx分xx秒 的形式
[u]复制代码[/u] 代码如下:
local function formatTime(time)     local hour = math.floor(time/3600);     local minute = math.fmod(math.floor(time/60), 60)     local second = math.fmod(time, 60)     local rtTime = string.format("%s:%s:%s", hour, minute, second)     return rtTime end
3、
[u]复制代码[/u] 代码如下:
--把1990.1.1至今的秒数,转化为年月日,时分 --endTime 单位毫秒 os.date("%Y-%m-%d  %H:%M",math.floor(endTime/1000))
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部