Library of Functions


Description


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

Usage and Arguments


os.time([table])

  • table: (optional) This table must have the fields year (four digits), month (1–12), day (1–31), and may have fields hour (0-23, the default is 12), min (0-59, the default is 0), sec (0-61, default is 0), and isdst (daylight saving flag, a boolean, the default is nil).

Returned Values


number: the time (either now or specified by the table) in seconds since the epoch.

Examples


-- create a lua table with a time in it.
-- in this case 29 December 1995 at 8:47pm
local t = {}
t.year = 1995
t.month = 12
t.day = 29
t.hour = 20
t.min = 47
t.sec = 0
 
-- this could be expressed all in one line:
 
local t2 = {year = 1995,month = 12,day = 29,hour = 20,min = 47,sec = 0}
 
-- output the current time to the debug console
fibaro:debug(os.time())
 
-- output the time in the table to the debug console
fibaro:debug(os.time(t))

See Also


Lua reference manual 5.2: os.time