Code:
Code: Select all
function timebetween(s,e)
timenow = os.date("*t")
year = timenow.year
month = timenow.month
day = timenow.day
s = s .. ":00"
e = e .. ":00"
shour = string.sub(s, 1, 2)
sminutes = string.sub(s, 4, 5)
sseconds = string.sub(s, 7, 8)
ehour = string.sub(e, 1, 2)
eminutes = string.sub(e, 4, 5)
eseconds = string.sub(e, 7, 8)
t1 = os.time()
t2 = os.time{year=year, month=month, day=day, hour=shour, min=sminutes, sec=sseconds}
t3 = os.time{year=year, month=month, day=day, hour=ehour, min=eminutes, sec=eseconds}
sdifference = os.difftime (t1, t2)
edifference = os.difftime (t1, t3)
isbetween = false
if sdifference >= 0 and edifference <= 0 then
isbetween = true
end
return isbetween
end
Example:
Code: Select all
if timebetween("00:01:00","06:00:00") then
Example 2:
Code: Select all
if timebetween("04:14:00","06:23:00") then
Credits:
Siewert Lameijer /
Siewert308SW