Setting a greeting based on user's time (Good morning, good afternoon…)

后端 未结 6 2148
孤街浪徒
孤街浪徒 2021-02-02 11:13

Can anyone extrapolate on how to implement a basic \"good evening\" or \"good morning\" based on the user\'s time setting?

Perhaps PHP will fetch the server time, but I

6条回答
  •  南旧
    南旧 (楼主)
    2021-02-02 11:25

    = "12" && $time < "17") {
            echo "Good afternoon";
        } else
        /* Should the time be between or equal to 1700 and 1900 hours, show good evening */
        if ($time >= "17" && $time < "19") {
            echo "Good evening";
        } else
        /* Finally, show good night if the time is greater than or equal to 1900 hours */
        if ($time >= "19") {
            echo "Good night";
        }
        ?>
    

提交回复
热议问题