reference/datetime/datetime/modify.xml
4cd196cb84cb840d2580804e39d3a5dc4682e312
...
...
@@ -1,6 +1,5 @@
1
1
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
-

4
3
<refentry xml:id="datetime.modify" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
5
4
<refnamediv>
6
5
<refname>DateTime::modify</refname>
...
...
@@ -11,13 +10,13 @@
11
10
<refsect1 role="description">
12
11
&reftitle.description;
13
12
<para>&style.oop;</para>
14
-
<methodsynopsis role="oop">
15
-
<modifier>public</modifier> <type>DateTime</type><methodname>DateTime::modify</methodname>
13
+
<methodsynopsis role="DateTime">
14
+
<modifier>public</modifier> <type class="union"><type>DateTime</type><type>false</type></type><methodname>DateTime::modify</methodname>
16
15
<methodparam><type>string</type><parameter>modifier</parameter></methodparam>
17
16
</methodsynopsis>
18
17
<para>&style.procedural;</para>
19
-
<methodsynopsis role="procedural">
20
-
<type>DateTime</type><methodname>date_modify</methodname>
18
+
<methodsynopsis>
19
+
<type class="union"><type>DateTime</type><type>false</type></type><methodname>date_modify</methodname>
21
20
<methodparam><type>DateTime</type><parameter>object</parameter></methodparam>
22
21
<methodparam><type>string</type><parameter>modifier</parameter></methodparam>
23
22
</methodsynopsis>
...
...
@@ -47,6 +46,40 @@
47
46
</para>
48
47
</refsect1>
49
48

49
+
<refsect1 role="errors">
50
+
&reftitle.errors;
51
+
<para>
52
+
Object Orientated API only: If an invalid Date/Time string is passed,
53
+
<exceptionname>DateMalformedStringException</exceptionname> is thrown.
54
+
</para>
55
+
</refsect1>
56
+

57
+
<refsect1 role="changelog">
58
+
&reftitle.changelog;
59
+
<informaltable>
60
+
<tgroup cols="2">
61
+
<thead>
62
+
<row>
63
+
<entry>&Version;</entry>
64
+
<entry>&Description;</entry>
65
+
</row>
66
+
</thead>
67
+
<tbody>
68
+
<row>
69
+
<entry>8.3.0</entry>
70
+
<entry>
71
+
Now throws
72
+
<exceptionname>DateMalformedStringException</exceptionname> with
73
+
<methodname>DateTime::modify</methodname> if an invalid string is
74
+
passed, instead of a warning.
75
+
<function>date_modify</function> has not been changed.
76
+
</entry>
77
+
</row>
78
+
</tbody>
79
+
</tgroup>
80
+
</informaltable>
81
+
</refsect1>
82
+

50
83
<refsect1 role="examples">
51
84
&reftitle.examples;
52
85
<example>
...
...
@@ -101,12 +134,40 @@ echo $date->format('Y-m-d') . "\n";
101
134
]]>
102
135
</screen>
103
136
</example>
137
+
<example>
138
+
<title>All formats of Date and Time are supported</title>
139
+
<programlisting role="php">
140
+
<![CDATA[
141
+
<?php
142
+
$date = new DateTime('2020-12-31');
143
+

144
+
$date->modify('July 1st, 2023');
145
+
echo $date->format('Y-m-d H:i') . "\n";
146
+

147
+
$date->modify('Monday next week');
148
+
echo $date->format('Y-m-d H:i') . "\n";
149
+

150
+
$date->modify('17:30');
151
+
echo $date->format('Y-m-d H:i') . "\n";
152
+
?>
153
+
]]>
154
+
</programlisting>
155
+
&example.outputs;
156
+
<screen>
157
+
<![CDATA[
158
+
2023-07-01 00:00
159
+
2023-07-03 00:00
160
+
2023-07-03 17:30
161
+
]]>
162
+
</screen>
163
+
</example>
104
164
</refsect1>
105
165

106
166
<refsect1 role="seealso">
107
167
&reftitle.seealso;
108
168
<simplelist>
109
169
<member><function>strtotime</function></member>
170
+
<member><function>DateTimeImmutable::modify</function></member>
110
171
<member><function>DateTime::add</function></member>
111
172
<member><function>DateTime::sub</function></member>
112
173
<member><function>DateTime::setDate</function></member>
...
...
@@ -117,7 +178,6 @@ echo $date->format('Y-m-d') . "\n";
117
178
</refsect1>
118
179

119
180
</refentry>
120
-

121
181
<!-- Keep this comment at the end of the file
122
182
Local variables:
123
183
mode: sgml
124
184