I want to get last 3 months name from current month. For example current month is August. So, I want the datas like these June, July, August. I have tried this code echo d
echo d
You are actually on the right track by using date and strtotime functions. Expanding it below to your requirements:
function getMonthStr($offset) { return date("F", strtotime("$offset months")); } $months = array_map('getMonthStr', range(-3,-1));