Q:

Write a PHP script to get the current month and previous three months

0

Write a PHP script to get the current month and previous three months.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<?php
echo date("M - Y")."\n";
echo date("M - Y",strtotime("-1 Months"))."\n";
echo date("M - Y",strtotime("-2 Months"))."\n";
echo date("M - Y",strtotime("-3 Months"))."\n";
?>
Sample Output:
Jul - 2017                                                          
Jun - 2017                                                          
May - 2017                                                          
Apr - 2017

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now