$year = 2010;
$month = 10;
How do I get the previous month 2010-09 and next month 2010-11?
You can just add 1 to the current month and then see if you crossed the year:
$next_year = $year;
$next_month = ++$month;
if($next_month == 13) {
$next_month = 1;
$next_year++;
}
Similarly for previous month you can do:
$prev_year = $year;
$prev_month = --$month;
if($prev_month == 0) {
$prev_month = 12;
$prev_year--;
}