reference/datetime/functions/mktime.xml
57e27d2a7615da2ee6de57ed27eb40b473d487cb
...
...
@@ -9,14 +9,13 @@
9
9
<refsect1 role="description">
10
10
&reftitle.description;
11
11
<methodsynopsis>
12
-
<type>int</type><methodname>mktime</methodname>
13
-
<methodparam choice="opt"><type>int</type><parameter>hour</parameter><initializer>date("H")</initializer></methodparam>
14
-
<methodparam choice="opt"><type>int</type><parameter>minute</parameter><initializer>date("i")</initializer></methodparam>
15
-
<methodparam choice="opt"><type>int</type><parameter>second</parameter><initializer>date("s")</initializer></methodparam>
16
-
<methodparam choice="opt"><type>int</type><parameter>month</parameter><initializer>date("n")</initializer></methodparam>
17
-
<methodparam choice="opt"><type>int</type><parameter>day</parameter><initializer>date("j")</initializer></methodparam>
18
-
<methodparam choice="opt"><type>int</type><parameter>year</parameter><initializer>date("Y")</initializer></methodparam>
19
-
<methodparam choice="opt"><type>int</type><parameter>is_dst</parameter><initializer>-1</initializer></methodparam>
12
+
<type class="union"><type>int</type><type>false</type></type><methodname>mktime</methodname>
13
+
<methodparam><type>int</type><parameter>hour</parameter></methodparam>
14
+
<methodparam choice="opt"><type class="union"><type>int</type><type>null</type></type><parameter>minute</parameter><initializer>&null;</initializer></methodparam>
15
+
<methodparam choice="opt"><type class="union"><type>int</type><type>null</type></type><parameter>second</parameter><initializer>&null;</initializer></methodparam>
16
+
<methodparam choice="opt"><type class="union"><type>int</type><type>null</type></type><parameter>month</parameter><initializer>&null;</initializer></methodparam>
17
+
<methodparam choice="opt"><type class="union"><type>int</type><type>null</type></type><parameter>day</parameter><initializer>&null;</initializer></methodparam>
18
+
<methodparam choice="opt"><type class="union"><type>int</type><type>null</type></type><parameter>year</parameter><initializer>&null;</initializer></methodparam>
20
19
</methodsynopsis>
21
20
<para>
22
21
Returns the Unix timestamp corresponding to the arguments
...
...
@@ -25,21 +24,24 @@
25
24
specified.
26
25
</para>
27
26
<para>
28
-
Arguments may be left out in order from right to left; any
29
-
arguments thus omitted will be set to the current value according
27
+
Any optional
28
+
arguments omitted or &null; will be set to the current value according
30
29
to the local date and time.
31
30
</para>
32
-
</refsect1>
33
-

34
-
<refsect1 role="notes">
35
-
&reftitle.notes;
36
-
<note>
31
+
<warning>
37
32
<para>
38
-
As of PHP 5.1, when called with no arguments, <function>mktime</function>
39
-
throws an <constant>E_STRICT</constant> notice: use the
40
-
<function>time</function> function instead.
33
+
Please note that the ordering of arguments is in an odd order:
34
+
<parameter>month</parameter>, <parameter>day</parameter>,
35
+
<parameter>year</parameter>, and not in the more reasonable order of
36
+
<parameter>year</parameter>, <parameter>month</parameter>,
37
+
<parameter>day</parameter>.
41
38
</para>
42
-
</note>
39
+
</warning>
40
+
<simpara>
41
+
Calling <function>mktime</function> without arguments is not supported,
42
+
and will result in an <classname>ArgumentCountError</classname>.
43
+
<function>time</function> can be used to get the current timestamp.
44
+
</simpara>
43
45
</refsect1>
44
46

45
47
<refsect1 role="parameters">
...
...
@@ -107,39 +109,10 @@
107
109
with values between 0-69 mapping to 2000-2069 and 70-100 to
108
110
1970-2000. On systems where time_t is a 32bit signed integer, as
109
111
most common today, the valid range for <parameter>year</parameter>
110
-
is somewhere between 1901 and 2038. However, before PHP 5.1.0 this
111
-
range was limited from 1970 to 2038 on some systems (e.g. Windows).
112
+
is somewhere between 1901 and 2038.
112
113
</para>
113
114
</listitem>
114
115
</varlistentry>
115
-
<varlistentry>
116
-
<term><parameter>is_dst</parameter></term>
117
-
<listitem>
118
-
<para>
119
-
This parameter can be set to 1 if the time is during daylight savings time (DST),
120
-
0 if it is not, or -1 (the default) if it is unknown whether the time is within
121
-
daylight savings time or not. If it's unknown, PHP tries to figure it out itself.
122
-
This can cause unexpected (but not incorrect) results.
123
-
Some times are invalid if DST is enabled on the system PHP is running on or
124
-
<parameter>is_dst</parameter> is set to 1. If DST is enabled in e.g. 2:00, all times
125
-
between 2:00 and 3:00 are invalid and <function>mktime</function> returns an undefined
126
-
(usually negative) value.
127
-
Some systems (e.g. Solaris 8) enable DST at midnight so time 0:30 of the day when DST
128
-
is enabled is evaluated as 23:30 of the previous day.
129
-
</para>
130
-
<note>
131
-
<para>
132
-
As of PHP 5.1.0, this parameter became deprecated. As a result, the
133
-
new timezone handling features should be used instead.
134
-
</para>
135
-
</note>
136
-
<note>
137
-
<para>
138
-
This parameter has been removed in PHP 7.0.0.
139
-
</para>
140
-
</note>
141
-
</listitem>
142
-
</varlistentry>
143
116
</variablelist>
144
117
</para>
145
118
</refsect1>
...
...
@@ -149,17 +122,10 @@
149
122
&reftitle.returnvalues;
150
123
<para>
151
124
<function>mktime</function> returns the Unix timestamp of the arguments
152
-
given.
153
-
If the arguments are invalid, the function returns &false; (before PHP 5.1
154
-
it returned <literal>-1</literal>).
125
+
given, or &false; if the timestamp doesn't fit in a PHP integer.
155
126
</para>
156
127
</refsect1>
157
128

158
-
<refsect1 role="errors">
159
-
&reftitle.errors;
160
-
&date.timezone.errors.description;
161
-
</refsect1>
162
-

163
129
<refsect1 role="changelog">
164
130
&reftitle.changelog;
165
131
<para>
...
...
@@ -173,39 +139,19 @@
173
139
</thead>
174
140
<tbody>
175
141
<row>
176
-
<entry>7.0.0</entry>
142
+
<entry>8.0.0</entry>
177
143
<entry>
178
-
<parameter>is_dst</parameter> parameter has been removed.
144
+
<parameter>hour</parameter> is no longer optional. If you need a Unix
145
+
timestamp, use <function>time</function>.
179
146
</entry>
180
147
</row>
181
148
<row>
182
-
<entry>5.3.0</entry>
149
+
<entry>8.0.0</entry>
183
150
<entry>
184
-
<function>mktime</function> now throws <constant>E_DEPRECATED</constant> notice
185
-
if the <parameter>is_dst</parameter> parameter is used.
151
+
<parameter>minute</parameter>, <parameter>second</parameter>, <parameter>month</parameter>,
152
+
<parameter>day</parameter> and <parameter>year</parameter> are nullable now.
186
153
</entry>
187
154
</row>
188
-
<row>
189
-
<entry>5.1.0</entry>
190
-
<entry>
191
-
The <parameter>is_dst</parameter> parameter became deprecated.
192
-
Made the function return &false; on error, instead of
193
-
<literal>-1</literal>.
194
-
Fixed the function to accept the year, month and day to be all passed
195
-
as zero.
196
-
</entry>
197
-
</row>
198
-
<row>
199
-
<entry>5.1.0</entry>
200
-
<entry>
201
-
When called with no arguments, <function>mktime</function> throws
202
-
<constant>E_STRICT</constant> notice. Use the
203
-
<function>time</function> function instead.
204
-
</entry>
205
-
</row>
206
-

207
-
&date.timezone.errors.changelog;
208
-

209
155
</tbody>
210
156
</tgroup>
211
157
</informaltable>
...
...
@@ -220,7 +166,7 @@
220
166
<programlisting role="php">
221
167
<![CDATA[
222
168
<?php
223
-
// Set the default timezone to use. Available as of PHP 5.1
169
+
// Set the default timezone to use.
224
170
date_default_timezone_set('UTC');
225
171

226
172
// Prints: July 1, 2000 is on a Saturday
...
...
@@ -276,21 +222,11 @@ echo strftime("Last day in Feb 2000 is: %d", $lastday);
276
222
</para>
277
223
</refsect1>
278
224

279
-
<refsect1 role="notes">
280
-
&reftitle.notes;
281
-
<caution>
282
-
<para>
283
-
Before PHP 5.1.0, negative timestamps were not supported under any known
284
-
version of Windows and some other systems as well. Therefore the range of
285
-
valid years was limited to 1970 through 2038.
286
-
</para>
287
-
</caution>
288
-
</refsect1>
289
-

290
225
<refsect1 role="seealso">
291
226
&reftitle.seealso;
292
227
<para>
293
228
<simplelist>
229
+
<member>The <classname>DateTimeImmutable</classname> class</member>
294
230
<member><function>checkdate</function></member>
295
231
<member><function>gmmktime</function></member>
296
232
<member><function>date</function></member>
...
...
@@ -299,7 +235,6 @@ echo strftime("Last day in Feb 2000 is: %d", $lastday);
299
235
</para>
300
236
</refsect1>
301
237
</refentry>
302
-

303
238
<!-- Keep this comment at the end of the file
304
239
Local variables:
305
240
mode: sgml
306
241