Created
March 11, 2015 17:35
-
-
Save eddieespinal/7d54174297cc92867bcd to your computer and use it in GitHub Desktop.
renderTimeOfDay
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
| private function renderTimeOfDay($user){ | |
| $now = DateTime::now(); | |
| $now->timezone($user['timezone']); // convert to user's timezone | |
| $hour = $now->time()->hour(); | |
| $result = 'night'; | |
| if($hour > 3 && $hour < 12){ | |
| $result = 'morning'; | |
| }elseif($hour < 17){ | |
| $result = 'afternoon'; | |
| }elseif($hour < 22){ | |
| $result = 'evening'; | |
| } | |
| return $result; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment