mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 08:28:54 +00:00
Fixed bug #77701: DateTime::createFromFormat does not set default parts
This commit is contained in:
parent
b90e4a6e43
commit
e5373bc761
1 changed files with 15 additions and 6 deletions
|
@ -208,7 +208,7 @@
|
|||
difference to UTC with colon between hours and minutes, or timezone
|
||||
abbreviation</entry>
|
||||
<entry>Examples: <literal>UTC</literal>, <literal>GMT</literal>,
|
||||
<literal>Atlantic/Azores</literal> or
|
||||
<literal>Atlantic/Azores</literal> or
|
||||
<literal>+0200</literal> or <literal>+02:00</literal> or
|
||||
<literal>EST</literal>, <literal>MDT</literal>
|
||||
</entry>
|
||||
|
@ -303,24 +303,28 @@
|
|||
parsing to fail and an error message is appended to the returned
|
||||
structure. You can query error messages with
|
||||
<methodname>DateTimeImmutable::getLastErrors</methodname>.
|
||||
</para>
|
||||
</para>
|
||||
<para>
|
||||
To include literal characters in <parameter>format</parameter>, you have
|
||||
to escape them with a backslash (<literal>\</literal>).
|
||||
</para>
|
||||
<para>
|
||||
If <parameter>format</parameter> does not contain the character
|
||||
<literal>!</literal> then portions of the generated time which are not
|
||||
<literal>!</literal> then portions of the generated date/time which are not
|
||||
specified in <parameter>format</parameter> will be set to the current
|
||||
system time.
|
||||
</para>
|
||||
<para>
|
||||
If <parameter>format</parameter> contains the
|
||||
character <literal>!</literal>, then portions of the generated
|
||||
time not provided in <parameter>format</parameter>, as well as
|
||||
date/time not provided in <parameter>format</parameter>, as well as
|
||||
values to the left-hand side of the <literal>!</literal>, will
|
||||
be set to corresponding values from the Unix epoch.
|
||||
</para>
|
||||
<para>
|
||||
If any time character is parsed, then all other time-related fields are
|
||||
set to "0", unless also parsed.
|
||||
</para>
|
||||
<para>
|
||||
The Unix epoch is 1970-01-01 00:00:00 UTC.
|
||||
</para>
|
||||
|
@ -428,17 +432,22 @@ echo "Format: $format; " . $date->format('Y-m-d H:i:s') . "\n";
|
|||
$format = '!d';
|
||||
$date = DateTimeImmutable::createFromFormat($format, '15');
|
||||
echo "Format: $format; " . $date->format('Y-m-d H:i:s') . "\n";
|
||||
|
||||
$format = 'i';
|
||||
$date = DateTimeImmutable::createFromFormat($format, '15');
|
||||
echo "Format: $format; " . $date->format('Y-m-d H:i:s') . "\n";
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Current time: 2010-04-23 10:29:35
|
||||
Format: Y-m-d; 2009-02-15 10:29:35
|
||||
Current time: 2022-06-02 15:50:46
|
||||
Format: Y-m-d; 2009-02-15 15:50:46
|
||||
Format: Y-m-d H:i:s; 2009-02-15 15:16:17
|
||||
Format: Y-m-!d H:i:s; 1970-01-15 15:16:17
|
||||
Format: !d; 1970-01-15 00:00:00
|
||||
Format: i; 2022-06-02 00:15:00
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
|
Loading…
Reference in a new issue