Alex Rivera | Logout

How can i get the current month and previous three months using PHP

Asked 2009-10-20T12:32:29.313
21

Will any one tell me how to get the current month and previous three months using PHP

For example:

echo date("y:M:d");

output will be: 09:Oct:20

But i need:

August

September

October

as the Output.

Thanks in advance...

Fero

Edit
Report

1 Answer

3

Try using the built in strtotime function in PHP and using 'F' for full textual output:

echo date('y:F:d'); // first month
echo date('y:F:d', strtotime('-1 month')); // previous month
echo date('y:F:d', strtotime('-2 month')); // second previous month
echo date('y:F:d', strtotime('-3 month')); // third previous month
answered 2009-10-20T12:37:51.550

Your Answer