获取php下个月当前时间标签:rq,下个月,year,month,获取,time,date,PHP,day From: https://www.cnblogs.com/zlf2000/p/17130992.html
public static function fq_time($time = "")
{
if (!$time) $time = time();
$arr = getdate($time);
//判断月份
$year = $arr['year'];
$month = $arr['mon'] + 1;
if ($month > 12) {
$year = $year + 1;
$month = 01;
}
$day = $arr['mday'];
if ($day > 28) {
if ($month == 2) {
if (($year % 4 == 0 && $year % 100 != 0) || ($year % 400 == 0)) {
if ($day >= 29) {
$rq = mktime(date("G", $time), date("i", $time), date("s", $time), $month, 01, $year);
$rq = date("Y-m-t H:i:s", $rq);
}
} else {
if ($day >= 28) {
$rq = mktime(date("G", $time), date("i", $time), date("s", $time), $month, 01, $year);
$rq = date("Y-m-t H:i:s", $rq);
}
}
} elseif ($month == 1 || $month == 3 || $month == 5 || $month == 7 || $month == 8 || $month == 10 || $month == 12) {
if ($day >= 31) {
$rq = mktime(date("G", $time), date("i", $time), date("s", $time), $month, 01, $year);
$rq = date("Y-m-t H:i:s", $rq);
}
} else {
if ($day >= 30) {
$rq = mktime(date("G", $time), date("i", $time), date("s", $time), $month, 01, $year);
$rq = date("Y-m-t H:i:s", $rq);
}
}
}
if (!isset($rq)) { //
$rq = date("Y-m-t H:i:s", $time);
$rq = mktime(date("G", $time), date("i", $time), date("s", $time), $month, $day, $year);
$rq = date("Y-m-d H:i:s", $rq);
}
$rq = strtotime($rq);
return $rq;
}