PHP下个月发行

PHP下个月发行,php,time,strftime,Php,Time,Strftime,我正试图通过php获取当前、下个月和下个月之后的数据 这是我当前的php: setlocale(LC_TIME, "de_DE.utf8"); $thismonth = strftime("%B"); $nextmonth = strftime( '%B', strtotime( '+1 month', mktime( 0, 0, 0, $month, 1, $year ) ) ); $overnextmonth = strftime( '%B', strtotime( '+2 month',

我正试图通过php获取当前、下个月和下个月之后的数据

这是我当前的php:

setlocale(LC_TIME, "de_DE.utf8");
$thismonth = strftime("%B");
$nextmonth = strftime( '%B', strtotime( '+1 month', mktime( 0, 0, 0, $month, 1, $year ) ) );
$overnextmonth = strftime( '%B', strtotime( '+2 month', mktime( 0, 0, 0, $month, 1, $year ) ) );
月份名称应该是德语,所以我使用的是
setlocale(LC_TIME,“de_de.utf8”)

输出为:1月(1月)、1月(1月)、2月(2月)。我无法解决这个问题。

使用这个
setlocale(LC_TIME,“de_de”)它会工作的

<?php
setlocale (LC_TIME,"de_DE"); 
echo $thismonth = strftime("%B");
echo $nextmonth = strftime( '%B', strtotime( '+1 month', mktime( 0, 0, 0, 1, 1, 2017 ) ) );
echo $overnextmonth = strftime( '%B', strtotime( '+2 month', mktime( 0, 0, 0, 2, 1, 2017 ) ) );

?>

输出


我建议远离strotime,使用php dateTime类

$date = new DateTime();
$date->add(new DateInterval('P1M')); // <-- adds 1 month to the current
echo $date->format('F') . "\n"; // it's now January so it outputs February
$date->add(new DateInterval('P1M'));
echo $date->format('F') . "\n"; // adds one more (total 2) months from original
$date=new DateTime();
$date->add(新的日期间隔('P1M'));//格式('F')。“\n”;//现在是一月,所以是二月
$date->add(新的日期间隔('P1M'));
echo$date->format('F')。“\n”;//从原始日期再增加一个月(总共2个月)

当前月份是一月。此输出将为“二月-三月”

请查看此项。注意:未定义变量:月在……中,
$month
$year
从何而来,而不是$month和$year。我将2017年的正常值设为年,将1设为月