请选择 进入手机版 | 继续访问电脑版
MSIPO技术圈 首页 IT技术 查看内容

Lua计算天数

2023-07-13

function GetDayDiff()
    local nowTime = os.time()
	local lastTime = GetLastTime()
	local nowData = os.date("*t", nowTime)
	local lastData = os.date("*t", lastTime)
	local diff
	if nowData and lastData then
		local num1 = os.time({year = nowData.year, month = nowData.month, day = nowData.day})
		local num2 = os.time({year = lastData.year, month = lastData.month, day = lastData.day})
		if num1 and num2 then
			diff = math.abs(num1 - num2) / (3600 * 24)
		end
	end
    return diff
end

相关阅读

热门文章

    手机版|MSIPO技术圈 皖ICP备19022944号-2

    Copyright © 2024, msipo.com

    返回顶部