获取两个时间的相隔天数

 

--获取两个时间的相隔天数
function GetDiffDays(utcSec1, utcSec2)
    local dt1 = os.date("*t", utcSec1)
    dt1.hour = 0 --忽略时分秒
    dt1.minute = 0
    dt1.second = 0
    utcSec1 = os.time(dt1)

    local dt2 = os.date("*t", utcSec2)
    dt2.hour = 0 --忽略时分秒
    dt2.minute = 0
    dt2.second = 0
    utcSec2 = os.time(dt2)

    local days = (utcSec2 - utcSec1) / (3600 * 24)
    return days
end

 

posted @ 2024-01-25 21:34  yanghui01  阅读(4)  评论(0编辑  收藏  举报