So I've done a bit of googling but I can't find much in the ways of doing this.
I'm wanting to store into a string today's date + a set amount of time, so for this instance let's say 1month and 1 day.
So errr for rough example of what I need, 'String = Date() + 1month + 1day' and the String would contain "13/10/2012".
Doesn't have to be 1 month and a day, just a rough example of what I mean. Anyone any idea how to do this in LUA?
print( os.date("%x") )
> 10/12/12
That good?
[editline]11th October 2012[/editline]
You can also use this to get the 4 digit year:
print( os.date("%d/%m/%Y") )
> 12/10/2012
Doesn't really answer my direct question, but google the LUA docs I see os.date() can be used to reverse a epoch time into a date. So I guess I could just add my value as an integer to the current epoch time and then convert it?
[editline]12th October 2012[/editline]
Thanks Chessnut. I guess your post made me go reread the od.date docs. Only this time I read them properly.
Only bad this is it figured out a month as the average. But just make it 31 days and it's close enough for me. I could do months but no point really. I tested it like so, fits my purpose :)
[lua]
local day = 86400
local week = 604800
local month = 2629743
local result
local etime = os.time()
--Vars set the values for times
result = os.date([[%d/%m/%y]],etime+day+month))
--then you can just add times to the current epoch
[/lua]
Sorry, you need to Log In to post a reply to this thread.