Lua时间转化的几个小例子
2017-07-19 11:53
204 查看
1、把时间 秒,转化为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秒 的形式
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.把1990.1.1至今的秒数,转化为年月日,时分。注:endTime 单位毫秒
os.date("%Y-%m-%d %H:%M",math.floor(endTime/1000))
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秒 的形式
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.把1990.1.1至今的秒数,转化为年月日,时分。注:endTime 单位毫秒
os.date("%Y-%m-%d %H:%M",math.floor(endTime/1000))
相关文章推荐
- Lua时间转化的几个小例子
- lua 的几个常识例子
- Lua时间转化 秒转换为日期
- [LUA]几个简单的luajava使用例子
- lua 时间转化
- lua的几个时间相关处理函数
- C++ LUA 获取当前时间并转化为字符串
- android之Uri的常用几个例子
- sql 存储过程 几个 简单例子
- 时间戳转化成时间格式:yyyy-MM--dd HH:mm:ss
- Java 中与时间有关的几个问题
- 通过lua-resty-upload实现文件上传的例子
- getTimeInMillis());转化时间格式
- 面向对象的 javascript的几个最重要的特性的讲解和实例以及全套javascript的例子.doc
- 关于java多线程的几个例子
- 从零开始学习使用iText PDF(2):跟着官网学几个例子
- 几个简单的voip的小例子
- luajava数值和对象传递的一个例子
- 程序空间换时间小例子
- xslt转化xml的最简单例子