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>isDST</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,37 +109,8 @@
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
-
</para>
113
-
</listitem>
114
-
</varlistentry>
115
-
<varlistentry>
116
-
<term><parameter>isDST</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>isDST</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.
112
+
is somewhere between 1901 and 2038.
129
113
</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
114
</listitem>
142
115
</varlistentry>
143
116
</variablelist>
...
...
@@ -149,15 +122,40 @@
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;
129
+
<refsect1 role="changelog">
130
+
&reftitle.changelog;
131
+
<para>
132
+
<informaltable>
133
+
<tgroup cols="2">
134
+
<thead>
135
+
<row>
136
+
<entry>&Version;</entry>
137
+
<entry>&Description;</entry>
138
+
</row>
139
+
</thead>
140
+
<tbody>
141
+
<row>
142
+
<entry>8.0.0</entry>
143
+
<entry>
144
+
<parameter>hour</parameter> is no longer optional. If you need a Unix
145
+
timestamp, use <function>time</function>.
146
+
</entry>
147
+
</row>
148
+
<row>
149
+
<entry>8.0.0</entry>
150
+
<entry>
151
+
<parameter>minute</parameter>, <parameter>second</parameter>, <parameter>month</parameter>,
152
+
<parameter>day</parameter> and <parameter>year</parameter> are nullable now.
153
+
</entry>
154
+
</row>
155
+
</tbody>
156
+
</tgroup>
157
+
</informaltable>
158
+
</para>
161
159
</refsect1>
162
160

163
161
<refsect1 role="examples">
...
...
@@ -168,7 +166,7 @@
168
166
<programlisting role="php">
169
167
<![CDATA[
170
168
<?php
171
-
// Set the default timezone to use. Available as of PHP 5.1
169
+
// Set the default timezone to use.
172
170
date_default_timezone_set('UTC');
173
171

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

227
-
<refsect1 role="notes">
228
-
&reftitle.notes;
229
-
<caution>
230
-
<para>
231
-
Before PHP 5.1.0, negative timestamps were not supported under any known
232
-
version of Windows and some other systems as well. Therefore the range of
233
-
valid years was limited to 1970 through 2038.
234
-
</para>
235
-
</caution>
236
-
</refsect1>
237
-

238
225
<refsect1 role="seealso">
239
226
&reftitle.seealso;
240
227
<para>
241
228
<simplelist>
229
+
<member>The <classname>DateTimeImmutable</classname> class</member>
242
230
<member><function>checkdate</function></member>
243
231
<member><function>gmmktime</function></member>
244
232
<member><function>date</function></member>
...
...
@@ -247,7 +235,6 @@ echo strftime("Last day in Feb 2000 is: %d", $lastday);
247
235
</para>
248
236
</refsect1>
249
237
</refentry>
250
-

251
238
<!-- Keep this comment at the end of the file
252
239
Local variables:
253
240
mode: sgml
254
241