We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 121
    • 36 Posts
    This is an auto-generated support/comment thread for Greeting.

    Use this forum to post any comments about this addition or any questions you have regarding its use.

    Brief Description:
    Would you like to greet your guests? This snippet will display either, Good Morning, Good Afternoon, or Good Evening, depending what time of the day it is.
      • 36446
      • 184 Posts
      HI!
      Just in case someone needs this: I altered the snippet so that it displays the "local time" of the user that visits the page - not the server time.
      Hope this helps someone:

      $HourOfDay = '<script type="text/javascript">
      var jetzt = new Date();
      var x = jetzt.getHours();
      if (x < 10) {
          greeting = "Good morning";
      } else if (x<20) {
          greeting = "Good day";
      } else {
          greeting = "Good evening";
      }
      document.write(greeting)
      </script>';
      echo $HourOfDay;
      
        https://www.beautyislife-shop.de - premium make-up!
        https://www.topsterne.de - sell it here!
        ---------------------------------------------------------
        • 36446
        • 184 Posts
        HI!
        Just in case someone needs this: I altered the snippet so that it displays the "local time" of the user that visits the page - not the server time.
        Hope this helps someone:

        $HourOfDay = '<script type="text/javascript">
        var jetzt = new Date();
        var x = jetzt.getHours();
        if (x < 10) {
            greeting = "Good morning";
        } else if (x<20) {
            greeting = "Good day";
        } else {
            greeting = "Good evening";
        }
        document.write(greeting)
        </script>';
        echo $HourOfDay;
        
          https://www.beautyislife-shop.de - premium make-up!
          https://www.topsterne.de - sell it here!
          ---------------------------------------------------------