Corona Lua计算两个日期之间的秒数

时间:2015-10-30 13:22:46

标签: date time lua corona

我有两个来自pickerWheel的日期,进入os.time表。我想在几秒钟内计算出这两者之间的差异。我已经有了一些东西,但在我自己做了数学之后,我认为它不那么准确。

local currentDate = os.date( '*t' )
local setTime = os.time{ year = myApp.y, month = myApp.m, day = myApp.d, hour = myApp.h, min = myApp.min, sec = 0 }
local endTime = os.time{ year = myApp.ey, month = myApp.em, day = myApp.ed, hour = myApp.h, min = myApp, sec = 0 }

local differenceInSec = endTime - setTime
local days = differenceInSec / 86400
local hours = days % 1 * 24
local minutes = hours % 1 * 60
local seconds = math.floor( minutes % 1 * 60 + 0.5 )

例如,setTime为1-11-2015,endTime为10-11-2015(DD-MM-YYYY)。它返回776460,但它应该返回大约864000对吗?有什么我做错了或有人可以帮助我吗?

0 个答案:

没有答案