time和date两个函数在Lua中实现所有的时钟查询功能。函数time在没有参数时返回当前时钟的数值。

t=os.date()
print(t)

05/07/19 16:49:18

-----------------------------
curtime=os.time()
temp = os.date("%x", curtime)
print(temp)

05/07/19
--------------------------------
urtime=os.time()
temp = os.date("*t", curtime)
print(temp.year,temp.month,temp.day)

2019 5 7

使用格式字符 "*t",创建一个时间表。
year a full year

month 01-12

day 01-31

hour 01-23

min 00-59

sec 00-59

--------------------------------