strtotime の挙動とか

strtotime の 月加算の処理がアレなわけだが、まぁ2月は日数が少ないので、仕方ない気もする。

[php] <?php $t = strtotime('2008-1-28'); echo date('Y-m-d', strtotime('+1 month', $t)) . "\n"; // 2008-02-28

$t = strtotime('2008-1-29'); echo date('Y-m-d', strtotime('+1 month', $t)) . "\n"; // 2008-02-29

$t = strtotime('2008-1-30'); echo date('Y-m-d', strtotime('+1 month', $t)) . "\n"; // 2008-03-01

$t = strtotime('2008-1-31'); echo date('Y-m-d', strtotime('+1 month', $t)) . "\n"; // 2008-03-02

$t = strtotime('2008-2-1'); echo date('Y-m-d', strtotime('+1 month', $t)) ." \n"; // 2008-03-01 [/php]