reference/datetime/datetime/modify.xml
c8ba91f7e546462dc66c2a11a7eab6f55c93915b
...
...
@@ -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">
13
+
<methodsynopsis role="DateTime">
15
14
<modifier>public</modifier> <type>DateTime</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>
...
...
@@ -43,10 +42,45 @@
43
42
<refsect1 role="returnvalues">
44
43
&reftitle.returnvalues;
45
44
<para>
46
-
&date.datetime.return.modifiedobjectorfalseforfailure;
45
+
Returns <classname>DateTime</classname> on success.
46
+
&return.falseforfailure.style.procedural;
47
+
</para>
48
+
</refsect1>
49
+

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

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

50
84
<refsect1 role="examples">
51
85
&reftitle.examples;
52
86
<example>
...
...
@@ -98,6 +132,33 @@ echo $date->format('Y-m-d') . "\n";
98
132
<![CDATA[
99
133
2001-01-31
100
134
2001-03-03
135
+
]]>
136
+
</screen>
137
+
</example>
138
+
<example>
139
+
<title>All formats of Date and Time are supported</title>
140
+
<programlisting role="php">
141
+
<![CDATA[
142
+
<?php
143
+
$date = new DateTime('2020-12-31');
144
+

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

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

151
+
$date->modify('17:30');
152
+
echo $date->format('Y-m-d H:i') . "\n";
153
+
?>
154
+
]]>
155
+
</programlisting>
156
+
&example.outputs;
157
+
<screen>
158
+
<![CDATA[
159
+
2023-07-01 00:00
160
+
2023-07-03 00:00
161
+
2023-07-03 17:30
101
162
]]>
102
163
</screen>
103
164
</example>
...
...
@@ -107,6 +168,7 @@ echo $date->format('Y-m-d') . "\n";
107
168
&reftitle.seealso;
108
169
<simplelist>
109
170
<member><function>strtotime</function></member>
171
+
<member><function>DateTimeImmutable::modify</function></member>
110
172
<member><function>DateTime::add</function></member>
111
173
<member><function>DateTime::sub</function></member>
112
174
<member><function>DateTime::setDate</function></member>
...
...
@@ -117,7 +179,6 @@ echo $date->format('Y-m-d') . "\n";
117
179
</refsect1>
118
180

119
181
</refentry>
120
-

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