开发中有用到,记录一下。
local year,month = os.date("%Y", os.time()), os.date("%m", os.time())+1 -- 正常是获取服务器给的时间来算
local dayAmount = os.date("%d", os.time({year=year, month=month, day=0})) -- 获取当月天数
os.time() 精确到1秒
os.clock() 运行程序cpu花费的时间 精确到0.01秒
本文详细介绍了在开发过程中如何使用Lua语言获取服务器时间、计算月份天数及时间精度的相关操作,包括os.time()和os.clock()函数的应用。
开发中有用到,记录一下。
local year,month = os.date("%Y", os.time()), os.date("%m", os.time())+1 -- 正常是获取服务器给的时间来算
local dayAmount = os.date("%d", os.time({year=year, month=month, day=0})) -- 获取当月天数
os.time() 精确到1秒
os.clock() 运行程序cpu花费的时间 精确到0.01秒
1987
1225
5168

被折叠的 条评论
为什么被折叠?
