Php 获取draw_calendar()函数的日期字符串

Php 获取draw_calendar()函数的日期字符串,php,datetime,Php,Datetime,我正在使用脚本,需要将日期参数设置为以下格式: 绘制日历(72009) 我想得到今天的月份和年份,以及下个月和下个月之后的月份(所以现在的月份,加上一个,加上一个)。我如何连续三次调用该函数来生成这三个日历,而只知道今天的月份和年份 -布兰登我相信还有更优雅的方式,但这是怎么回事: function increment(&$month, &$year) { if (++$month > 12) { $month -= 12; $yea

我正在使用脚本,需要将日期参数设置为以下格式:

绘制日历(72009)

我想得到今天的月份和年份,以及下个月和下个月之后的月份(所以现在的月份,加上一个,加上一个)。我如何连续三次调用该函数来生成这三个日历,而只知道今天的月份和年份


-布兰登

我相信还有更优雅的方式,但这是怎么回事:

function increment(&$month, &$year) {
    if (++$month > 12) {
        $month -= 12;
        $year++;
    }
}
$month = 11;
$year = 2009;
echo "Month: $month, Year: $year\n";
# Outputs Month: 11, Year: 2009
increment($month, $year);
echo "Month: $month, Year: $year\n";
# Outputs Month: 12, Year: 2009
increment($month, $year);
echo "Month: $month, Year: $year\n";
# Outputs Month: 1, Year: 2010
$onemonth = strtotime('+1 month');
$twomonth = strtotime('+2 month');

draw_calendar(date('n'), date('Y'));
draw_calendar(date('n', $onemonth), date('Y', $onemonth));
draw_calendar(date('n', $twomonth), date('Y', $twomonth));

谢谢,我想这会有用的。我认为我不能使用字符串,但是strotime()函数很有用。