mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 08:58:56 +00:00
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:
parent
fe271d65f0
commit
0e209aff72
1 changed files with 23 additions and 0 deletions
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue