How to tell what the previous month/year was with tick()?

So this is the code i have now: while wait() do time = math.floor(tick()) year = 1970 --startdate January 1, - Pastebin.com

and i have no idea how i would tell what the previous month was and how would i tell that the previous month was last year? Please Help!

os.date() is a much better function because you can get it to give you it in a format where that stuff has already been calculated.

An example of what it returns:

{
year = 246,
month = 12,
day = 10,
hour = 3,
min = 56,
sec = 7
}

Using this could, you could simply subtract 1 from the month value to get the previous month.

If needed, you can also convert one of these date tables into a timestamp similar to what tick() gives you using os.time(table).

thing is how do you get a UNIX time stamp?

Edited.

thing is how do you get a UNIX time stamp of the current time?

The same way - os.time() on its own will do it, or you can do what I just said and do:

local Date = os.date()
local Timestamp = os.time(Date)

so take away 2.628e+6 from os.time() and then run it through os.date()?

Yeah, as long as 2.628e+6 is how many seconds are in a month.

alright! thanks! :slight_smile:

1 Like