how to read time with os.time() ?

I was wondering how do i read the time from the value i get with os.time( )

let’s say i get this from the console with print( os.time() )

1328713552
1328713553
1328713554
1328713555
1328713556

what exactly is the time? does it include the date/month/year as well?
what i want to do is change the “theme” of my game depending
on what time of day it is, dark theme with moonlight for night time
and colorful theme with sunshine for day time [import]uid: 114118 topic_id: 21581 reply_id: 321581[/import]

xplatgaming,
Time functionality in lua is really simple…

  1. OS.time() -> This function gives you the date and time in seconds…It also accepts the datetime lua table returned by os.date()
  2. OS.date() -> Gives you back a lua table that has all the basic date and time attributes
    os.time() is printing the current date and time in seconds

so taking ur example

local time = os.time() -- This is time in seconds  
local dateTime = os.date("\*t", time) -- \*t is the one of the, there are other formats too.  
print(dateTime.year, dateTime.month, dateTime.hour, dateTime.min)  

So now using the dateTime label you can put in your own custom logic.

Hope this helps.

Bejoy [import]uid: 84539 topic_id: 21581 reply_id: 85560[/import]

additionally you can peruse

http://lua-users.org/wiki/DayOfWeekAndDaysInMonthExample

or

http://pgl.yoyo.org/luai/i/os.date

c
[import]uid: 24 topic_id: 21581 reply_id: 85614[/import]