Last active
May 4, 2018 20:10
-
-
Save init90/8324d773d502ca5801608e20a1327e86 to your computer and use it in GitHub Desktop.
PHP get month interval.
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
| public static function getMonthInterval($date) { | |
| $month_interval = []; | |
| // Get start month date. | |
| $date_obj = new \DateTime($date); | |
| $date_obj->modify('first day of this month'); | |
| $month_interval['start'] = $date_obj->getTimestamp(); | |
| // Get end month date. | |
| $date_obj->modify('last day of this month'); | |
| $date_obj->setTime(23, 59, 59); | |
| $month_interval['end'] = $date_obj->getTimestamp(); | |
| return $month_interval; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment