Getting Correct Day Of Month

HI

im trying to obtain the date in 1 day from now.

so if today is 30 April 2019 (you will need to change your date to 30 April 2019 manually)

what is the correct way to achieve this

im using this code but using +1 gives 32 as answer rather than 1 , April Being 30 days only.

t = os.date("*t")
t.day = t.day + 1
position = os.time(t)

print ("Monthday= "…t.day)

I would probably do this:

local tomorrowsDate = os.date("\*t", os.time() + 86400) print("month = "..tomorrowsDate.month) print("day = "..tomorrowsDate.day)

If you provide a unix timestamp as the second argument to os.date() it returns the date for that timestamp rather than the current time.

Likewise, if you don’t pass any arguments to os.time() it automatically returns the current unix time. So I just add one day’s worth of seconds on (86400 seconds), and then pass that as the second argument to the os.date() function. 

Brilliant , Thanks So Much…

I would probably do this:

local tomorrowsDate = os.date("\*t", os.time() + 86400) print("month = "..tomorrowsDate.month) print("day = "..tomorrowsDate.day)

If you provide a unix timestamp as the second argument to os.date() it returns the date for that timestamp rather than the current time.

Likewise, if you don’t pass any arguments to os.time() it automatically returns the current unix time. So I just add one day’s worth of seconds on (86400 seconds), and then pass that as the second argument to the os.date() function. 

Brilliant , Thanks So Much…