<?php function greet() { $hour = date('G'); // get the hour in 24-hour format if ($hour < 12) { echo 'Good Morning'; } else if ($hour < 17) { echo 'Good Afternoon'; } else { echo 'Good Night'; } } greet(); // calling the function