这是完成任务的 100% 工作代码
<?php
$month = date('n');
$year = date('Y');
$IsLeapYear = date('L');
$NextYear = $year + 1;
$IsNextYearLeap = date('L', mktime(0, 0, 0, 1, 1, $NextYear));
$TodaysDate = date('j');
if (strlen($month+3) < 10)
{
$UpdateMonth = "0".($month+3);
}
if ($month > 9) {
if ($month == 10)
{
$UpdateMonth = "01";
}
else if ($month == 11)
{
$UpdateMonth = "02";
}
else
{
$UpdateMonth = "03";
}
}
if (($month != 10) && ($month != 11) && ($month != 12))
{
if(($month&1) && ($TodaysDate != 31))
{
$DateAfterThreeMonths = $year."-".$UpdateMonth."-".$TodaysDate;
}
else if (($month&1) && ($TodaysDate == 31))
{
$DateAfterThreeMonths = $year."-".$UpdateMonth."-30";
}
else {
$DateAfterThreeMonths = $year."-".$UpdateMonth."-".$TodaysDate;
}
}
else if ($month == 11)
{
if (($TodaysDate == 28) || ($TodaysDate == 29) || ($TodaysDate == 30))
{
if ($IsLeapYear == 1)
{
$DateAfterThreeMonths = ($year+1)."-".$UpdateMonth."-28";
}
else if ($IsNextYearLeap == 1)
{
$DateAfterThreeMonths = ($year+1)."-".$UpdateMonth."-29";
}
else
{
$DateAfterThreeMonths = ($year+1)."-".$UpdateMonth."-28";
}
}
else
{
$DateAfterThreeMonths = ($year+1)."-".$UpdateMonth."-".$TodaysDate;
}
}
else
{
$DateAfterThreeMonths = ($year+1)."-".$UpdateMonth."-".$TodaysDate;
}
echo $DateAfterThreeMonths;
?>
我们可以使用顶部的这段代码手动检查这些东西:-
// Just change the values of $month, $year, $TodaysDate
$month = 11;
$year = 2012;
$IsLeapYear = date('L');
$NextYear = $year + 1;
$IsNextYearLeap = date('L', mktime(0, 0, 0, 1, 1, $NextYear));
$TodaysDate = 31;
只需复制并粘贴代码,在您的浏览器中查看 :)