私はこのコードで文字列fromatedの日付に月を追加してい:のstrtotime()広告の月変化の分
$str ="2017-01-29 14:22:57";
$effectiveDate = strtotime("+1 months", strtotime($str));
echo "<br>";
echo date('Y-m-d h:m:s',strtotime($str));
echo "<br>";
echo date('Y-m-d h:m:s',$effectiveDate);
出力されています:
2017-01-29 02:01:57
2017-03-01 02:03:57
私は疑問に思って、なぜです少し変わった?毎月1分の変化があるようです。
「m」=> *の場合はhttp://php.net/manual/en/function.date.php m \t **月の数値表現先行ゼロ付き\t 01〜12 * - あなたが望む**分**のための「私」。 'h:m:s'の代わりに' h:i:s'を実行するのがその理由です。 –
ちょうどヒント: '$ effectiveDate = strtotime(" $ str +1 months ");' – JustOnUnderMillions
も参考にしてください:http://php.net/manual/de/class.datetime.php#datetime.constants .types – JustOnUnderMillions