我正在寻找获得上个月第一天和最后一天的最佳方式。我使用它们进行SQL查询以获取上个月的统计信息。获得上个月第一天和最后一天的最佳方式?
我认为这是最好的方式,更优化但不是更强化,任何人都有另一种方法来做同样的事情吗?
$month_ini = date("Y-m-d", mktime(0, 0, 0, date("m", strtotime("-1 month")), 1, date("Y", strtotime("-1 month"))));
$month_end = date("Y-m-d", mktime(0, 0, 0, date("m", strtotime("-1 month")), date("t", strtotime("-1 month")), date("Y", strtotime("-1 month"))));
谢谢!!
可能重复:// stackoverflow.com/questions/1686724/php-last-day-of-the-month) – DaveRandom 2012-03-16 10:33:14
你有没有试过strtotime? – 2012-03-16 10:33:30
http://stackoverflow.com/questions/2680501/how-can-i-find-the-first-and-last-date-in-a-month-using-php – 2012-03-16 10:33:36