askIT

PHP previous month

You are here
Support > PHP previous month

vote_up

0

vote_down

Posted by Administrator · 25 September 2018 · Report

$month = date("m");
$year = date("Y");

// Previous month
if($month == "01"){
$month_previous = "12";
$year_previous = $year-1;
}
else{
$month_previous = $month-1;
$year_previous = $year;
}

1_180303121314.jpg
Administrator

Reply