mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 08:58:56 +00:00
Fix example: was wrong due to putting month into minute.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@298407 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
0ee9a7d35f
commit
b058ed9338
1 changed files with 13 additions and 17 deletions
|
@ -89,32 +89,28 @@
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
date_default_timezone_set('Europe/London');
|
||||
$date = new DateTime('2000-01-01');
|
||||
echo $date->format('Y-m-d H:i:s') . "\n";
|
||||
|
||||
$datetime = new DateTime('2008-08-03 12:35:23');
|
||||
echo $datetime->format('Y-m-d H:i:s') . "\n";
|
||||
$date->setTime(14, 55);
|
||||
echo $date->format('Y-m-d H:i:s') . "\n";
|
||||
|
||||
$datetime->setTime(14, 55, 24);
|
||||
echo $datetime->format('Y-m-d H:i:s') . "\n";
|
||||
$date->setTime(14, 55, 24);
|
||||
echo $date->format('Y-m-d H:i:s') . "\n";
|
||||
|
||||
// Warning: Does not increment the hour!
|
||||
// This is because the hour has been set (14) - see date_modify()
|
||||
$datetime->setTime($datetime->format('H'), $datetime->format('n') + 6);
|
||||
echo $datetime->format('Y-m-d H:i:s') . "\n";
|
||||
|
||||
// *Does* increment the day, because the day has not been set
|
||||
$datetime->setTime($datetime->format('H') + 12, $datetime->format('n'));
|
||||
echo $datetime->format('Y-m-d H:i:s') . "\n";
|
||||
// Values exceeding ranges are added to their parent values.
|
||||
$date->setTime(14, 65, 24);
|
||||
echo $date->format('Y-m-d H:i:s') . "\n";
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
2008-08-03 12:35:23
|
||||
2008-08-03 14:55:24
|
||||
2008-08-03 14:14:00
|
||||
2008-08-04 02:08:00
|
||||
2000-01-01 00:00:00
|
||||
2000-01-01 14:55:00
|
||||
2000-01-01 14:55:24
|
||||
2000-01-01 15:05:24
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
|
Loading…
Reference in a new issue