我有以下说法。要么我从查询字符串中得到日期,要么我得到今天的日期。在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