Greet according to the time of day Challenge
Write a program that greets a user depending on what time of day (GMT) it is.

Output
A string (printed or returned) according to these rules:

If the time is 06:00 to 11:59 the greeting has to be &quot;Good morning&quot;
If the time is 12:00 to 17:59 the greeting has to be &quot;Good afternoon&quot;
If the time is 18:00 to 19:59 the greeting has to be &quot;Good evening&quot;
If the time is 20:00 to 05:59 the greeting has to be &quot;Zzz&quot;


Clarifications

There is no input
The times and greetings must be exactly as shown
The time zone is +0 GMT

Examples
Time: 14:45 -&gt; Good afternoon

Time: 05:59 -&gt; Zzz

Time: 9:23 -&gt; Good morning

Time: 18:00 -&gt; Good evening
JavaScript (ES6), 87 bytes

As noticed by TFeld, my original formula was overcomplicated. We can just do:

_=&gt;['Zzz','Good morning','Good afternoon','Good evening'][new Date().getHours()%20/6|0]


Try it online!

Or test this version that takes the hour as parameter.



JavaScript (ES6), 90 bytes

_=&gt;['Zzz','Good morning','Good afternoon','Good evening'][new Date().getHours()*7%20%7&gt;&gt;1]


Try it online!

Or test this version that takes the hour as parameter.

Formula

Given the current hour \$h\$, we find the appropriate greeting index \$i\$ with:

$$i=\left\lfloor\frac{((7\times h) \bmod 20) \bmod 7}{2}\right\rfloor$$

A good thing about this formula is that it does not require any parenthesis once converted to JS:

h * 7 % 20 % 7 &gt;&gt; 1


Table

 Hour |  *7 | mod 20 | mod 7 | &gt;&gt; 1
------+-----+--------+-------+------
   0  |   0 |    0   |   0   |   0
   1  |   7 |    7   |   0   |   0
   2  |  14 |   14   |   0   |   0
   3  |  21 |    1   |   1   |   0
   4  |  28 |    8   |   1   |   0
   5  |  35 |   15   |   1   |   0
   6  |  42 |    2   |   2   |   1
   7  |  49 |    9   |   2   |   1
   8  |  56 |   16   |   2   |   1
   9  |  63 |    3   |   3   |   1
  10  |  70 |   10   |   3   |   1
  11  |  77 |   17   |   3   |   1
  12  |  84 |    4   |   4   |   2
  13  |  91 |   11   |   4   |   2
  14  |  98 |   18   |   4   |   2
  15  | 105 |    5   |   5   |   2
  16  | 112 |   12   |   5   |   2
  17  | 119 |   19   |   5   |   2
  18  | 126 |    6   |   6   |   3
  19  | 133 |   13   |   6   |   3
  20  | 140 |    0   |   0   |   0
  21  | 147 |    7   |   0   |   0
  22  | 154 |   14   |   0   |   0
  23  | 161 |    1   |   1   |   0