App with time slots

Hello, I would need to make an app with time slots or, in a time slot eg. 8.00-13.00, there must be written a text eg Good morning while in the remaining time slot eg 13.00-8.00, there must be another text eg. Have a good evening. I have already put a clock that gets the time from the phone.
The problem is that it doesn't update correctly.


Goodbye!

The military has a system for combining hours and minutes into one number, like 13:30 is called 1330 hours. This makes for easy comparisons.

To get military time, multiply the hour (0-23) by 100 and add the minutes.

Now all you need is a single comparison using military time.

Also, if you arrange your if/then/elseif tests in a ladder with descending order comparisons, each rung of the ladder should give you a range.

if military time > 2200 then good evening
else if > 1200 then good afternoon
else if military time > 0 then good morning

(adjust boundaries to taste, but keep them in descending value.)

1 Like

The minutes are irrelevant in your case for the comparison... follow @ABG's suggestion... or simpler:

If hour > 19
Then Good evening
Elseif hour > 11
Then Good afternoon.
Else Good Morning

Taifun

1 Like