2
votes

Is it possible to calculate the 3rd last day of the month using:

echo gmdate('Y-m-d H:i:s' , mktime({what goes here}));

Some examples of the result I want:

  1. January 28th
  2. February 25th / 26th
  3. March 28th
  4. April 27th
  5. May 29th
  6. June 27th
  7. July 28th
  8. August 28th
  9. September 27th
  10. October 28th
  11. November 27th
  12. December 28th
1
All of those dates are consistent except for february. Do you really need to calculate those?noia_0328

1 Answers

1
votes
$year = 2014;

foreach(range(1,12) as $month) {
    $time = gmdate("F jS",strtotime('-3 days',strtotime(date("Y-$month-t",strtotime("$year-$month-01")))));
    print $time . "\n";
}

Output

January 28th
February 25th
March 28th
April 27th
May 28th
June 27th
July 28th
August 28th
September 27th
October 28th
November 27th
December 28th