BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Problem with Time INPUT

Hello,
I have a problem with Time Input Widget. I use only start and stop time (Without day etc. selections). In my software I need 3 time day - “morning”, “day” and “night”. “Morning” and “day” working corectly but I have problem with “night”.
I use the 24h system
When I try to set time for example:
Start - 21:00 and Stop - 22:00 - everything is OK
but when I try to set time like that:
Start - 21:00 and Stop - 01:00 - timer does not start
Have you any idea why ??

It’s probably to do with the way that you’re handling the data that is coming from the widget in your code.

I’m guessing that you have an if statement that says something like “if the current time is greater than or equal to the start time and less than the stop time then activate the output”.

In this scenario, if the start time is 21:00 and the stop time is 01:00, and the current time is 21:01 then the first part of the if statement evaluates as true (21:01 is greater than or equal to 21:00) but the second part evaluates as false (21:01 is not less than 01:00).

If this is the case then you would need to make your code more sophisticated to handle a scenario where the stop time is on the following day.

Pete.