reference/datetime/datetimeimmutable/construct.xml
8b4c3d8dc5e190fbd5d84eede38a4da13537043d
...
...
@@ -10,13 +10,13 @@
10
10
<refsect1 role="description">
11
11
&reftitle.description;
12
12
<para>&style.oop;</para>
13
-
<constructorsynopsis>
13
+
<constructorsynopsis role="DateTimeImmutable">
14
14
<modifier>public</modifier> <methodname>DateTimeImmutable::__construct</methodname>
15
15
<methodparam choice="opt"><type>string</type><parameter>datetime</parameter><initializer>"now"</initializer></methodparam>
16
16
<methodparam choice="opt"><type class="union"><type>DateTimeZone</type><type>null</type></type><parameter>timezone</parameter><initializer>&null;</initializer></methodparam>
17
17
</constructorsynopsis>
18
18
<para>&style.procedural;</para>
19
-
<methodsynopsis role="procedural">
19
+
<methodsynopsis>
20
20
<type class="union"><type>DateTimeImmutable</type><type>false</type></type><methodname>date_create_immutable</methodname>
21
21
<methodparam choice="opt"><type>string</type><parameter>datetime</parameter><initializer>"now"</initializer></methodparam>
22
22
<methodparam choice="opt"><type class="union"><type>DateTimeZone</type><type>null</type></type><parameter>timezone</parameter><initializer>&null;</initializer></methodparam>
...
...
@@ -70,14 +70,15 @@
70
70
&reftitle.returnvalues;
71
71
<para>
72
72
Returns a new DateTimeImmutable instance.
73
-
&return.falseforfailure.style.procedural;
74
73
</para>
75
74
</refsect1>
76
75

77
76
<refsect1 role="errors">
78
77
&reftitle.errors;
79
78
<para>
80
-
Emits <classname>Exception</classname> in case of an error.
79
+
If an invalid Date/Time string is passed,
80
+
<exceptionname>DateMalformedStringException</exceptionname> is thrown.
81
+
Previous to PHP 8.3, this was <exceptionname>Exception</exceptionname>.
81
82
</para>
82
83
</refsect1>
83
84

...
...
@@ -94,6 +95,15 @@
94
95
</thead>
95
96
<tbody>
96
97
<row>
98
+
<entry>8.3.0</entry>
99
+
<entry>
100
+
Now throws
101
+
<exceptionname>DateMalformedStringException</exceptionname> if an
102
+
invalid string is passed, instead of
103
+
<exceptionname>Exception</exceptionname>.
104
+
</entry>
105
+
</row>
106
+
<row>
97
107
<entry>7.1.0</entry>
98
108
<entry>From now on microseconds are filled with actual value. Not with '00000'.</entry>
99
109
</row>
...
...
@@ -164,7 +174,7 @@ $date = new DateTimeImmutable();
164
174
echo $date->format('Y-m-d H:i:sP') . "\n";
165
175

166
176
// Current date/time in the specified time zone.
167
-
$date = new DateTimeImmutable(null, new DateTimeZone('Pacific/Nauru'));
177
+
$date = new DateTimeImmutable('now', new DateTimeZone('Pacific/Nauru'));
168
178
echo $date->format('Y-m-d H:i:sP') . "\n";
169
179

170
180
// Using a UNIX timestamp. Notice the result is in the UTC time zone.
171
181