date_default_timezone_set("America/Chicago");
$time = time();
$hour = date("G",$time);
echo $hour;
if(($hour >= 0) && ($hour <=3)) {
$greeting == 'Good Evening';
}
elseif(($hour >= 4) && ($hour <=11)) {
$greeting == 'Good Morning';
}
elseif(($hour >= 12) && ($hour <=18)){
$greeting == 'Good Afternoon';
}
elseif(($hour >= 19) && ($hour <= 24)) {
$greeting == 'Good Evening';
}
echo $greeting;
First, I prefilled "America/Chicago", I would like this to be automatically detected based on current user's local time not UTC.
Second, as you can see, I echoed $hour, as a test, to see what was displaying. At the time I did this, $hour was 8. But, my if statements were never "true", therefore, no greeting was outputted, At the time, 8, should have displayed Good Morning as the greeting. I am positive I'm probably making some silly mistake, but I've been working with this code for three hours. Please help! Thank You!