I have the following code which I am using to get a greeting to display to the user based on what the time is. The print out I get is ‘Good Morning,00 the date and time now is xx/xx/xx xx:xx’. The problem is obviously the 00 after the greeting. What have I done wrong?
<?php
$hour = date("H");
if ($hour <= '11' ) {
echo 'Good Morning,';
}
else {
echo 'Good Afternoon,';
};
echo $hour . ' the date and time now is ' . date('d/m/y H:i');
?>
Get rid of the “$hour .” in the echo.
The code should be,
Note you also had an extra space after the “is” that probably wasn’t intentional.