函数:os.time 格式化时间
函数名称:格式化时间
函数功能:将时间转成时间戳
函数方法
exampletime = os.time(timeout)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| timeout | table | 否 | 指定格式化的时间, 不写默认为当前时间 |
timeout 参数介绍
| 格式符 | 类型 | 说明 |
|---|---|---|
| hour | number | 小时 |
| min | number | 分钟 |
| wday | number | 星期 |
| day | number | 日期 |
| month | number | 月份 |
| year | number | 年 |
| sec | number | 秒 |
| yday | number | 一年当中第几天 |
| isds | boolean | 夏时令 |
| 返回值 | 类型 | 说明 |
|---|---|---|
| exampletime | number | 转换后的时间戳 |
函数示例
--获取当前时间的时间戳
local exampletime = os.time();
dialog("转换后的时间戳:"..exampletime)
dialog(os.date("%c",exampletime))
local exampletime = os.time({year=2020,month=12,day=25,hour=8,min=0,sec=0})
dialog("转换后的时间戳:"..exampletime)
dialog(os.date("%c",exampletime))