Skip to content

Instantly share code, notes, and snippets.

@SilasRodrigues19
Last active March 21, 2023 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SilasRodrigues19/830783ece1c0d7c011f6f31700249162 to your computer and use it in GitHub Desktop.
Save SilasRodrigues19/830783ece1c0d7c011f6f31700249162 to your computer and use it in GitHub Desktop.
<?php
date_default_timezone_set('America/Sao_Paulo');
$currentDate = new DateTime();
$currentHour = $currentDate->format('H');
$currentMinutes = $currentDate->format('i');
if ($currentHour >= 5 && $currentHour < 12) {
$message = "tenha um bom dia";
} elseif ($currentHour >= 12 && $currentHour < 18) {
$message = "tenha uma boa tarde";
} else {
$message = "tenha uma boa noite";
}
echo "Agora são {$currentHour}:{$currentMinutes}, {$message}";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment