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.

time range verification
#1
Hello

I'm trying with a script to check if I'm within a certain time frame, which crosses midnight.

In practice, if I am in the range between 20.00 and 06.00 the next day I must have true.

then I will replace the fixed values with settable values, which way to follow?

Thanks so much
Reply
#2
Here's an exerpt where I'm checking if the time is between 0200 and 0700 hours, you can modify this to do what you need. 

now = os.date('*t')
time = {hour = now.hour,}

if time.hour > 2 and time.hour < 7 then *do stuff*
else  *do stuff*
end
Reply
#3
The above example is correct but if you also need minutes in the range then check this example: https://forum.logicmachine.net/showthrea...1#pid21201
Reply
#4
(10.06.2021, 09:27)admin Wrote: The above example is correct but if you also need minutes in the range then check this example: https://forum.logicmachine.net/showthrea...1#pid21201

tkank's
Reply


Forum Jump: