Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
を含むスクリプト内
date('Y-m-d', strtotime('first day of last month'))
バージョン5.3.10(localhost)では、たとえば「2012-03-01」を取得します。
バージョン5.2.17(リモートホスト)では、「1969-12-31」を取得します。
両方のバージョンで期待される(たとえば、「2012-03-01」)結果を返す式はありますか?
mktime()関数を使用する必要があります。
<?php echo date('Y-m-d', mktime(0,0,0,date('n')-1,1,date('Y'))); //2012-03-01 ?>
See In Action
これは PHP 5.2.17の既知のバグです。