版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Lg632/article/details/84064844
/**
* Explain: 用于根据时间获取时间段时间
*/
public function start_end_time($time_tyupe_string, $time_string){
switch ($time_tyupe_string) {
case 'date':
$firstday = date('Y-m-d 00:00:00', strtotime($time_string));
$lastday = date('Y-m-d 23:59:59', strtotime($time_string));
break;
case 'month':
$firstday = date('Y-m-01 00:00:00', strtotime($time_string));
$lastday = date('Y-m-d 23:59:59', strtotime("$firstday +1 month -1 day"));
break;
case 'quarter':
$firstday = date('Y-m-d', strtotime($time_string['start_date'])).' 00:00:00';
$lastday = date('Y-m-d', strtotime($time_string['end_date'])).' 24:00:00';
break;
case 'years':
$firstday = date('Y-01-01 00:00:00', strtotime($time_string));
$lastday = date('Y-m-d 23:59:59', strtotime("$firstday +1 year -1 day"));
break;
default:
break;
}
$return_time = [$firstday,$lastday];
return $return_time;
}