$_POST['month_year'] = APR-2015
$mth = "April";
$pre_mth = Date("F", strtotime($mth . " last month"));
$pre_mth
gives me only month name which is 'March'.
How can I fetch previous month-year in the format MAR-2015
?
$_POST['month_year'] = APR-2015
$mth = "April";
$pre_mth = Date("F", strtotime($mth . " last month"));
$pre_mth
gives me only month name which is 'March'.
How can I fetch previous month-year in the format MAR-2015
?
See the date function options:
$pre_mth = strtoupper(date("M-Y", strtotime($mth . " last month")));
// strtoupper just to uppercase 'Mar' to 'MAR'