PHP program to display Good Morning / Good Afternoon / Good Evening message according to current time.

Write a PHP program to display Good Morning / Good Afternoon / Good Evening message according to current time.


In this tutorial, you will learn how to display Good Morning / Good Afternoon / Good Evening message according to current time in php.

Below is the php script to display Good Morning / Good Afternoon / Good Evening message according to current time in php.

<html>
<head>
    <title>PHP Program for Displaying Greeting depending upon Current Time Zone</title>
</head>
<body>

    <h3>Displaying Greeting depending upon Current Time Zone</h3>
   
    <?php
        date_default_timezone_set("Asia/Kolkata");  
        $h = date('G');

        if($h>=5 && $h<=11)
        {
            echo "Good morning";
        }
        else if($h>=12 && $h<=15)
        {
            echo "Good afternoon";
        }
        else
        {
            echo "Good evening";
        }
    ?>  

</body>
</html>


Thanks for reading.

© Copyright - 2018 - 2022 | All rights reserved at Funda of Web IT