os.difftime()

Type Function
Library os.*
Return value Number
Revision Release 2024.3703
Keywords difftime, time, date, difference
See also os.time()
os.clock()
os.date()

Overview

Returns the number of seconds from time t1 to time t2. In POSIX, Windows, and some other systems, this value is exactly t2 - t1.

Syntax

os.difftime( newerTime, olderTime )
newerTime (required)

Number. First time parameter.

olderTime (required)

Number. Second time parameter.

Example

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