| 1234567891011121314151617181920212223242526272829303132 |
- <?php
- namespace addons\DoubleCopy\common\services;
- use DateTime;
- class BaseService extends \services\common\BaseService
- {
- public function __construct($config = [])
- {
- parent::__construct($config);
- }
- /**
- * 给定一个开始和结束时间,是否超过了一个月
- *
- * @param string $startDate
- * @param string $endDate
- *
- * @return bool
- */
- public function isMoreThanOneMonth(string $startDate, string $endDate) {
- $start = new DateTime($startDate);
- $end = new DateTime($endDate);
- // 计算两个日期之间的间隔
- $interval = $start->diff($end);
- // 如果间隔的月份数大于等于1,则返回true
- return $interval->m >= 1 || $interval->y >= 1;
- }
- }
|