how do i get a greeting for logged in uses by the time of day

I can see two very obvious flaws that might be holding you back.

$t=date("H"); gives you a formatted date as a string while if ($t<"12") and else if ($t<"18") are trying to do maths on words.

Consider $t=(int)date("H"); (force the answer to be a whole number) with if ($t<12) and else if ($t<18) which at least does maths with numbers.