//获取给定时间的周日时间或月末时间或每天 private function endDate ($time, $type = 1, $openTime = '20:00:00') { if ($type == 1) { return date('Y-m-d ' . $openTime, $time); } elseif ($type == 2) { $w = strftime('%u', $time);//获取是周几的数字1-7 return date('Y-m-d ' . $openTime, $time + (7 - $w) * 24 * 60 * 60); } elseif ($type == 3) { $t = date('t', $time);//获取给定日期月末是几号,数字 return date('Y-m-' . $t . ' ' . $openTime, $time); } return ''; }