PHP获取X个月后的时间戳
function getMonthXTString($x)
{
$year = date('Y');
$month = date('m');
$day = date('d');
$month = $month + $x;
if ($month > 12) {
$year++;
$month = $month - 12;
}
return strtotime("{$year}-{$month}-{$day}");
}
根据测试php 28日29日30日31日都是会自动转换的,所以不需要给他进行判断
如果要精确到秒可以改为
return strtotime("{$year}-{$month}-{$day}"." ".date(H:i:s));