Take another look at your
if
condition:
if (UTC_hours > 22 && UTC_hours < 8)
Whatever value is in
UTC_hours
, it cannot be both
"greater than 22" and
"less than 8" at the same time.
You probably mean to use an "OR" instead of an "AND":
if (UTC_hours > 22 || UTC_hours < 8)
However, this will only disable the button at
11 PM. At 10:59 PM, the hour is still 10, so it's not
greater than 10.
If you want to disable the button at
10 PM, you need to change the first condition:
if (UTC_hours >= 22 || UTC_hours < 8)
You should also bear in mind that this is using UTC time based on the user's clock. It won't use your server's time-zone; it won't use your client's time-zone; and if the client's clock is wrong, the code will enable/disable the button at the wrong time.