PHP program to greet the user based on time

In this program, you will be welcoming users based upon a time if time is less than 12 pm you will print good morning, between 12 pm to 5 pm print good afternoon, between 5 pm to 8 pm good evening, and greater than 8 pm print good night

$dat = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
if($date < 12) 
  echo "Good morning to everyone"; 
else if($date < 17) 
  echo "Good afternoon to everyone";
else if($date<20)
  echo "Good evening to everyone"; 
  echo "Good night to everyone"; 


Good night to everyone