Add example of how adding months can be problematic.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@299008 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Daniel Convissor 2010-05-05 03:05:09 +00:00
parent fe271d65f0
commit 0e209aff72

View file

@ -93,6 +93,29 @@ echo date_format($date, 'Y-m-d');
<screen>
<![CDATA[
2006-12-13
]]>
</screen>
</example>
<example>
<title>Beware when adding or subtracting months</title>
<programlisting role="php">
<![CDATA[
<?php
$date = new DateTime('2000-12-31');
$date->modify('+1 month');
echo $date->format('Y-m-d') . "\n";
$date->modify('+1 month');
echo $date->format('Y-m-d') . "\n";
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
2001-01-31
2001-03-03
]]>
</screen>
</example>