svn: /phpdoc/en/trunk/reference/datetime/datetime/ modify.xml
| From: | Daniel Convissor | Date: | Wed, 05 May 2010 03:05:09 +0000 |
| Subject: | svn: /phpdoc/en/trunk/reference/datetime/datetime/ modify.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-6582@lists.php.net to get a copy of this message | ||
danielc Wed, 05 May 2010 03:05:09 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=299008
Log:
Add example of how adding months can be problematic.
Changed paths:
U phpdoc/en/trunk/reference/datetime/datetime/modify.xml
Modified: phpdoc/en/trunk/reference/datetime/datetime/modify.xml
===================================================================
--- phpdoc/en/trunk/reference/datetime/datetime/modify.xml 2010-05-05 03:02:15 UTC (rev 299007)
+++ phpdoc/en/trunk/reference/datetime/datetime/modify.xml 2010-05-05 03:05:09 UTC (rev 299008)
@@ -96,6 +96,29 @@
]]>
</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>
</refsect1>
<refsect1 role="seealso">