Created
April 30, 2017 13:51
-
-
Save alandbh/c58c6e0ce785f44d4912cd689332b939 to your computer and use it in GitHub Desktop.
Print greetings to user, based in current date / time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
------------------------------- | |
Imprime uma mensagem de cumprimento ao usuário baseado na hora local | |
Alan | |
*/ | |
date_default_timezone_set("America/Sao_Paulo"); // Seta o timezone para o nosso fuso-horário | |
$time = date("H"); // pega a hora atual no formato 24h | |
if ($time < "8") { | |
$msg = "Chegou cedo, hein,"; | |
} else | |
if ($time >= "8" && $time < "12") { | |
$msg = "Bom dia,"; | |
} else | |
if ($time >= "12" && $time < "18") { | |
$msg = "Boa tarde,"; | |
} else | |
if ($time >= "18" && $time < "20") { | |
$msg = "Boa noite,"; | |
} else | |
if ($time >= "20" && $time < "21") { | |
$msg = "Vai perder a novela,"; | |
} else | |
if ($time >= "21") { | |
$msg = "Durma bem,"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment