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

4
3
<refentry xml:id="datetime.settime" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
5
4
<refnamediv>
6
5
<refname>DateTime::setTime</refname>
...
...
@@ -11,23 +10,33 @@
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::setTime</methodname>
16
15
<methodparam><type>int</type><parameter>hour</parameter></methodparam>
17
16
<methodparam><type>int</type><parameter>minute</parameter></methodparam>
18
17
<methodparam choice="opt"><type>int</type><parameter>second</parameter><initializer>0</initializer></methodparam>
18
+
<methodparam choice="opt"><type>int</type><parameter>microsecond</parameter><initializer>0</initializer></methodparam>
19
19
</methodsynopsis>
20
20
<para>&style.procedural;</para>
21
-
<methodsynopsis role="procedural">
21
+
<methodsynopsis>
22
22
<type>DateTime</type><methodname>date_time_set</methodname>
23
23
<methodparam><type>DateTime</type><parameter>object</parameter></methodparam>
24
24
<methodparam><type>int</type><parameter>hour</parameter></methodparam>
25
25
<methodparam><type>int</type><parameter>minute</parameter></methodparam>
26
26
<methodparam choice="opt"><type>int</type><parameter>second</parameter><initializer>0</initializer></methodparam>
27
+
<methodparam choice="opt"><type>int</type><parameter>microsecond</parameter><initializer>0</initializer></methodparam>
27
28
</methodsynopsis>
28
29
<para>
29
30
Resets the current time of the DateTime object to a different time.
30
31
</para>
32
+
<para>
33
+
Like <methodname>DateTimeImmutable::setTime</methodname> but works with
34
+
<classname>DateTime</classname>.
35
+
</para>
36
+
<para>
37
+
The procedural version takes the <classname>DateTime</classname> object as
38
+
its first argument.
39
+
</para>
31
40
</refsect1>
32
41

33
42
<refsect1 role="parameters">
...
...
@@ -58,13 +67,21 @@
58
67
</para>
59
68
</listitem>
60
69
</varlistentry>
70
+
<varlistentry>
71
+
<term><parameter>microsecond</parameter></term>
72
+
<listitem>
73
+
<para>
74
+
Microsecond of the time.
75
+
</para>
76
+
</listitem>
77
+
</varlistentry>
61
78
</variablelist>
62
79
</refsect1>
63
80

64
81
<refsect1 role="returnvalues">
65
82
&reftitle.returnvalues;
66
83
<para>
67
-
&date.datetime.return.modifiedobjectorfalseforfailure;
84
+
&date.datetime.return.modifiedobject;
68
85
</para>
69
86
</refsect1>
70
87

...
...
@@ -79,95 +96,29 @@
79
96
</row>
80
97
</thead>
81
98
<tbody>
82
-
&date.datetime.retval.changelog;
99
+
<row>
100
+
<entry>8.1.0</entry>
101
+
<entry>The behaviour with double existing hours (during the fall-back
102
+
DST transition) changed. Previously PHP would pick the second occurrence
103
+
(after the DST transition), instead of the first occurrence (before DST
104
+
transition).</entry>
105
+
</row>
106
+
<row>
107
+
<entry>7.1.0</entry>
108
+
<entry>The <parameter>microsecond</parameter> parameter was added.</entry>
109
+
</row>
83
110
</tbody>
84
111
</tgroup>
85
112
</informaltable>
86
113
</refsect1>
87
114

88
-
<refsect1 role="examples">
89
-
&reftitle.examples;
90
-
<example>
91
-
<title><function>DateTime::setTime</function> example</title>
92
-
<para>&style.oop;</para>
93
-
<programlisting role="php">
94
-
<![CDATA[
95
-
<?php
96
-
$date = new DateTime('2001-01-01');
97
-

98
-
$date->setTime(14, 55);
99
-
echo $date->format('Y-m-d H:i:s') . "\n";
100
-

101
-
$date->setTime(14, 55, 24);
102
-
echo $date->format('Y-m-d H:i:s') . "\n";
103
-
?>
104
-
]]>
105
-
</programlisting>
106
-
<para>&style.procedural;</para>
107
-
<programlisting role="php">
108
-
<![CDATA[
109
-
<?php
110
-
$date = date_create('2001-01-01');
111
-

112
-
date_time_set($date, 14, 55);
113
-
echo date_format($date, 'Y-m-d H:i:s') . "\n";
114
-

115
-
date_time_set($date, 14, 55, 24);
116
-
echo date_format($date, 'Y-m-d H:i:s') . "\n";
117
-
?>
118
-
]]>
119
-
</programlisting>
120
-
&examples.outputs.similar;
121
-
<screen>
122
-
<![CDATA[
123
-
2001-01-01 14:55:00
124
-
2001-01-01 14:55:24
125
-
]]>
126
-
</screen>
127
-
</example>
128
-
<example>
129
-
<title>Values exceeding ranges are added to their parent values</title>
130
-
<programlisting role="php">
131
-
<![CDATA[
132
-
<?php
133
-
$date = new DateTime('2001-01-01');
134
-

135
-
$date->setTime(14, 55, 24);
136
-
echo $date->format('Y-m-d H:i:s') . "\n";
137
-

138
-
$date->setTime(14, 55, 65);
139
-
echo $date->format('Y-m-d H:i:s') . "\n";
140
-

141
-
$date->setTime(14, 65, 24);
142
-
echo $date->format('Y-m-d H:i:s') . "\n";
143
-

144
-
$date->setTime(25, 55, 24);
145
-
echo $date->format('Y-m-d H:i:s') . "\n";
146
-
?>
147
-
]]>
148
-
</programlisting>
149
-
&example.outputs;
150
-
<screen>
151
-
<![CDATA[
152
-
2001-01-01 14:55:24
153
-
2001-01-01 14:56:05
154
-
2001-01-01 15:05:24
155
-
2001-01-02 01:55:24
156
-
]]>
157
-
</screen>
158
-
</example>
159
-
</refsect1>
160
-

161
115
<refsect1 role="seealso">
162
116
&reftitle.seealso;
163
117
<simplelist>
164
-
<member><function>DateTime::setDate</function></member>
165
-
<member><function>DateTime::setISODate</function></member>
118
+
<member><function>DateTimeImmutable::setTime</function></member>
166
119
</simplelist>
167
120
</refsect1>
168
-

169
121
</refentry>
170
-

171
122
<!-- Keep this comment at the end of the file
172
123
Local variables:
173
124
mode: sgml
174
125