Member_2_6478753
asked on
php year month loop function
$curYear = date('Y');
for ($k = $curYear; $k >= 2011; $k--)
for ($i = 12; $i >= 1; $i--)
$monthName = date("F", mktime(0, 0, 0, $i, 10));
what i want to modify in this code is
like if year = 2012 i will start from 2012 and the current month ...and decrement the month till January..
and if year less than curr year like 2011 fetch all month..
let say we are in year 2013 so the output is
2013 from month 12 to 1
and 2012 from month 12 to 1
and 2011 from month 12 to 1
i want to modify it to be like
2013 from current month to 1
and 2012 from month 12 to 1
and 2011 from month 12 to 1
Please read the article here. It will tell you everything you need to know about the basics of handling PHP and SQL date/time values.
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_201-Handling-date-and-time-in-PHP-and-MySQL.html
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_201-Handling-date-and-time-in-PHP-and-MySQL.html
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window