57 文字
1 分
PHPで先月の求め方
print date('n', strtotime('- 1 second ', strtotime(date('Y-m-01'))));アプローチは、今月の1日から1秒引いた時の月。
strtotime('-1 month'); はちゃんと返してくれない!
例えば、7/31の時。
print date('n', strtotime('- 1 month', strtotime(date('2009-07-31')))); // 7が返るからダメ! PHPで先月の求め方
https://blog.teraren.com/posts/phpで先月の求め方/