Created
June 20, 2021 03:33
-
-
Save nasrulhazim/039ff696b5d56abcad326ea7affb9015 to your computer and use it in GitHub Desktop.
Simple Time Period Helper
This file contains 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
<?php | |
if (! function_exists('time_period')) { | |
function time_period() | |
{ | |
// Morning: 6 a.m.-noon | |
// Afternoon: noon-6 p.m. | |
// Evening: 6-9 p.m. | |
$value = (int) date('H'); | |
if (in_array($value, range(0, 12))) { | |
return __('Morning'); | |
} | |
if (in_array($value, range(13, 15))) { | |
return __('Afternoon'); | |
} | |
if (in_array($value, range(16, 23))) { | |
return __('Evening'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reference: https://wgntv.com/weather/how-do-you-define-daytime-and-evening-times-in-a-weather-forecast/