Answer the question
In order to leave comments, you need to log in
How to display an inscription depending on the time in php using strftime?
It is necessary, depending on the hour, to display this or that message using strftime.
What am I doing wrong?)
<?php
$hour = strftime("%H");
if ($hour >= 6 && $hour <= 9 ) {
echo "good morning"
{elseif ($hour >=21 && $hour <= 6){
echo "good afternoon";
?>
Answer the question
In order to leave comments, you need to log in
With brackets, complete rubbish, a semicolon is missing
$hour = strftime("%H");
if ($hour >= 6 && $hour <= 9 ) {
echo "доброе утро";
} elseif ($hour >=21 && $hour <= 6) {
echo "добрый день";
}
strftime returns a string and you compare it to a number.
The first condition will still work, thanks to automatic type casting, but the second is more difficult.
I'm trying to imagine which number is greater than 21, but at the same time less than 6, and I can't.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question