PHP获取下个月今天时间

获取php下个月当前时间
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;
}
posted @ 2023-02-17 17:30  zlf2000  阅读(587)  评论(0编辑  收藏  举报