Jump to content

Official HackingCampus Chat > https://discord.gg/e6DSwy3

Sign in to follow this  
PRG

Cum afisezi un mesaj pe site in functie de ora folosind un simplu cod PHP

Recommended Posts

   <?php
    /* Aceasta stabileste variabila $time la ora curenta in formatul ceasului de 24 de ore */
    $time = date("H");
    /* Seteaza variabila $timezone pentru a deveni fusul orar curent */
    $timezone = date("e");
    /* Daca ora este mai mica de 12:00 afiseaza mesajul Buna dimineata */
    if ($time < "12") {
        echo "Buna dimineata!";
    } else
    /* Daca ora este intre 12:00 si ora 17:00 afiseaza mesajul: Dupa-amiaza placuta */
    if ($time >= "12" && $time < "17") {
        echo "Dupa-amiaza palcuta!";
    } else
    /* Daca ora este intre 17:00 si ora 20:00 afiseaza mesajul: Buna seara */
    if ($time >= "17" && $time < "20") {
        echo "Buna seara!";
    } else
    /* Daca ora este 20:00 sau trecut de ora 20:00 afiseaza mesajul: Noapte buna */
    if ($time >= "20") {
        echo "Noapte buna!";
    }
    ?>

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...