php 获取当前季度信息
程序员文章站
2024-03-14 14:04:04
...
调用此方法
function get_quarter($month){
if ($month == 1 || $month == 2 || $month == 3) {
$start = date('Y-01-01 00:00:00');
$end = date("Y-03-31 23:59:59");
$quarter = 1; //第一季度
} elseif ($month == 4 || $month == 5 || $month == 6) {
$start = date('Y-04-01 00:00:00');
$end = date("Y-06-30 23:59:59");
$quarter = 2; //第二季度
} elseif ($month == 7 || $month == 8 || $month == 9) {
$start = date('Y-07-01 00:00:00');
$end = date("Y-09-30 23:59:59");
$quarter = 3; //第三季度
} else {
$start = date('Y-10-01 00:00:00');
$end = date("Y-12-31 23:59:59");
$quarter = 4; //第四季度
}
$data['quarter'] = $quarter;
$data['start'] = $start;
$data['end'] = $end;
return $data;
}