This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

lua table range of dates
#4
Hi,

You made it way to complicated (: Try this:
Code:
time = os.time()

data = {}

for i = 1, 365 do
  datetimetable = os.date('*t', time)
  data[ i ] = { day_num = datetimetable.wday, week_day = os.date('%A', time), day_in_month = datetimetable.day, month_date = datetimetable.month}
  time = time - 86400 -- substract 1 day
end

log(data)
To have a table like in your initial question try this:
Code:
time = os.time()

data = {}

for i = 1, 14 do
  data['day ' .. i] = { date =  os.date('%x', time), day = os.date('%A', time)}
  time = time - 86400 -- substract 1 day
end

log(data)
BR,

Erwin
Reply


Messages In This Thread
lua table range of dates - by benanderson_475 - 20.08.2020, 05:17
RE: lua table range of dates - by admin - 20.08.2020, 06:46
RE: lua table range of date - by Erwin van der Zwart - 21.08.2020, 07:21
RE: lua table range of dates - by Dré - 20.06.2021, 11:48
RE: lua table range of dates - by admin - 20.06.2021, 12:25

Forum Jump: