I am making a contest that will start on a certain date(let’s say March 13, 12:30) I want a to make a counter that counts down the seconds until it reaches that date. I have done some research on how to get dates and so on(lol), but I am still confused as to how to make this function.
This is what I made so far:
local function dateToSeconds(year,yday,hour,min,sec)
local returnValue
local localData = os.date("*t", os.time())
if year == localData.year then
if yday == localData.yday then
if hour == localData.hour then
if min == localData.min then
returnValue = sec - localData.sec
else
local minutes = (min - localData.min) * 60
returnValue = (min + sec) - localData.sec
end
else
local hours = ((hour - localData.hour) * 60)*60
returnValue = (min + sec + hours) - (localData.min*60) - localData.sec
end
else
local ydays = (((yday - localData.yday) * 24)*60)*60
returnValue = (min + sec + hour + ydays) - (localData.min*60) - ((localData.hour*60)*60) - localData.sec
end
else
local years = ((((year - localData.year) *365)*24)*60)*60
returnValue = (min + sec + hour + yday + years) - (localData.min*60) - ((localData.hour*60)*60) - (((localData.ydays* 24)*60)*60) - localData.sec
end
return returnValue
end