私は先月の最初と最後の日を取得する最良の方法を探しています。先月の統計を取得するために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"))));
ありがとう!!
可能重複[PHP月の最後の日](のhttp:// stackoverflow.com/questions/1686724/php-last-day-of-the-month) – DaveRandom
あなたはstrtotimeを試しましたか? –
http://stackoverflow.com/questions/2680501/how-can-i-find-the-first-and-last-date-in-a-month-using-php –