os.time()

Type Function
Library os.*
Return value Number
Revision 2017.3060
Keywords os, time, date
See also os.date()
os.clock()
system.getTimer()

Overview

Returns the current time in seconds from 1970 when called without arguments, or a time representing the date and time specified by the given table.

Syntax

os.time( table )
table (optional)

Table. table specifying a time to convert to seconds. If table is present, it must have fields year, month, and day, and may have additional fields hour, min, sec, and isdst (for a description of these fields, see the os.date function).

Example

local t = os.date( '*t' )  -- get table of current date and time
print( os.time( t ) )      -- print date & time as number of seconds
-- OUTPUT: 1287516614
 
t.min = t.min + 1          -- add one to the minute field
print( os.time( t ) )      -- print number of seconds (increases by 60 seconds)
-- OUTPUT: 1287516674