私は次のような声明があります。どちらか私はクエリ文字列から日付を取得するか、今日の日付を取得します。PHPで日付を追加
次に、現在、前、次の月を取得する必要があります。
は、私は私が "のstrtotime"
$selecteddate = ($_GET ['s'] == "")
? getdate()
: strtotime ($_GET ['s']) ;
$previousMonth = strtotime(date("Y-m-d", $selecteddate) . " +1 month");
$previousMonthName = $previousMonth[month];
print $previousMonthName;
$month = $selecteddate[month];
/*編集を使用して、間違ったつもりだと思います*/
$selecteddate = ($_GET ['s'] == "")
? getdate()
: strtotime ($_GET ['s']) ;
$previousMonth = strtotime(" -1 month", $selecteddate);
$nextMonth = strtotime(" +1 month", $selecteddate);
$previousMonthName = date("F",$previousMonth); //Jan
$nextMonthName = date("F",$nextMonth); // Jan
$month = $selecteddate[month]; // Aug
re。あなたの編集; '$ selecteddate'は(' getdate() 'から返された)配列か(' strtotime() 'から返された)整数を保持します。 'strtotime()'への後の呼び出しは、配列を渡してもうまくいきません。 – salathe