PHP strtotime('now + seconds') の思い出
2008-12-23 で思い出したのですが、 strtotime('now + seconds') という式でハマったことがあります。
コード
<?php echo date('Ymd', strtotime('now + seconds'));
PHP 4.3.9 の出力
20081224
PHP 5.2.5 の出力
19700101
どこで見たか
だいぶまえの http://phpicalendar.net/ の実装で
config.ini.php
$second_offset = ''; // The time in seconds between your time and your server's time.
となっていて、一方 多くの場所で
$getdate = date('Ymd', strtotime("now + $second_offset seconds"));
とかやってた。
どうやって直すか
strtotime("now + 0 seconds") なら 意図通り現在の時刻を返してくれる。 先の例なら
$second_offset = '0'; // The time in seconds between your time and your server's time.
とする。
なぜそうなるか
知りません。