<?php
$m0 = new DateTime("first day of last month");
echo $m0->format('Y-m-d') . PHP_EOL;
$m1 = new DateTime("last day of last month");
echo $m1->format('Y-m-d') . PHP_EOL;
$m2 = new DateTime("first day of February 2012");
echo $m2->format('Y-m-d') . PHP_EOL;
$m3 = new DateTime("first day of 2012-02");
echo $m3->format('Y-m-d') . PHP_EOL;
?>
Reference:
http://stackoverflow.com/questions/9735604/the-best-way-to-get-the-first-and-last-day-of-last-month
No comments:
Post a Comment