Skip to content

Instantly share code, notes, and snippets.

@alandbh
Created April 30, 2017 13:51
Show Gist options
  • Save alandbh/c58c6e0ce785f44d4912cd689332b939 to your computer and use it in GitHub Desktop.
Save alandbh/c58c6e0ce785f44d4912cd689332b939 to your computer and use it in GitHub Desktop.
Print greetings to user, based in current date / time
/*
-------------------------------
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