stfc_boy
02-17-2010, 09:11 AM
Hello all,
I have a script which finds the next month of the year (and year if it's December)
<?php
$the_month = '01'; //Set as Jan
$the_year = '1999'; //Set as 1999
$temp = $the_month+1;
$the_next_month = str_pad($temp>12 ? $temp-12 : $temp,2,'0',0);
$the_next_year = $temp>12 ? $the_year+1 : $the_year;
echo $the_next_month,'-',$the_next_year;
?>
But I can't work this out for the previous month. Can anyone kindly help?
Thanks
I have a script which finds the next month of the year (and year if it's December)
<?php
$the_month = '01'; //Set as Jan
$the_year = '1999'; //Set as 1999
$temp = $the_month+1;
$the_next_month = str_pad($temp>12 ? $temp-12 : $temp,2,'0',0);
$the_next_year = $temp>12 ? $the_year+1 : $the_year;
echo $the_next_month,'-',$the_next_year;
?>
But I can't work this out for the previous month. Can anyone kindly help?
Thanks