Welcome to WebmasterWorld Guest from 188.8.131.52
So if the user enters 2007/12/01, i will display data for dec 07. Now i want to compare dec 07 data with nov 07 data as well. So how can i calculate the previous month from the input?
$date = "2007/12/01";
$datearray = explode("/", $date);
$month = $datearray;
echo("This month is ". $month . "<br>");
$lastmonth = $month - 1;
echo("Last month was " . $lastmonth);
Just be careful that if the month is January, this will calculate last month as 0 (not 12). An if statement or two will take care of that.