1

私はコーディングとphpの世界に不慣れで、関数strtotimemktime関数が異なる結果を返す理由に混乱しています。

$endyear = date('Y', strtotime('+5 years')); //returns 2011 - 2015
$endyear = date('Y', mktime(0,0,0,0,0,$year+5)); //returns 2011 - 2014

編集

変数$yearの値は$2011です。

4

1 に答える 1

3

月と日の引数にゼロを使用しています。これは基本的に

Day 0 = Last day of the previous month
Month 0 = Last month of the previous year

それはすべてドキュメントにあります-http://php.net/manual/en/function.mktime.php

于 2011-05-05T00:23:02.147 に答える