os.difftime()

类型 函数
os.*
返回值 数字
修订 2024.3703 版
关键字 difftime,时间,日期,差异
另请参阅 os.time()
os.clock()
os.date()

概述

从时间 t1 返回到时间 t2 的秒数。在 POSIX、Windows 和某些其他系统中,此值恰好为t2 - t1.

语法

os.difftime( newerTime, olderTime )
newerTime (必填)

数字. 第一个时间参数。

olderTime (必填)

数字. 第二个时间参数。

示例

local olderTime = os.time()
 
-- Print the elasped time
local function dspTime()
    print( "Time elasped = " .. os.difftime( os.time(), olderTime ) )
end

timer.performWithDelay( 2000, dspTime )  -- Wait 2 seconds before calling function