reference/datetime/functions/date.xml
7f385d3239d0df073e2208fb0c3c243ef13553bb
...
...
@@ -3,7 +3,7 @@
3
3
<refentry xml:id="function.date" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
4
4
<refnamediv>
5
5
<refname>date</refname>
6
-
<refpurpose>Format a local time/date</refpurpose>
6
+
<refpurpose>Format a Unix timestamp</refpurpose>
7
7
</refnamediv>
8
8

9
9
<refsect1 role="description">
...
...
@@ -15,10 +15,18 @@
15
15
</methodsynopsis>
16
16
<para>
17
17
Returns a string formatted according to the given format string using the
18
-
given integer <parameter>timestamp</parameter> or the current time
19
-
if no timestamp is given. In other words, <parameter>timestamp</parameter>
18
+
given integer <parameter>timestamp</parameter> (Unix timestamp) or the current time
19
+
if no timestamp is given. In other words, <parameter>timestamp</parameter>
20
20
is optional and defaults to the value of <function>time</function>.
21
21
</para>
22
+
<warning>
23
+
<para>
24
+
Unix timestamps do not handle timezones. Use the
25
+
<classname>DateTimeImmutable</classname> class, and its
26
+
<methodname>DateTimeInterface::format</methodname> formatting method to
27
+
format date/time information with a timezone attached.
28
+
</para>
29
+
</warning>
22
30
</refsect1>
23
31

24
32
<refsect1 role="parameters">
...
...
@@ -28,8 +36,17 @@
28
36
<term><parameter>format</parameter></term>
29
37
<listitem>
30
38
<para>
31
-
Format accepted by <function>DateTimeInterface::format</function>.
39
+
Format accepted by <methodname>DateTimeInterface::format</methodname>.
32
40
</para>
41
+
<note>
42
+
<simpara>
43
+
<function>date</function> will always generate
44
+
<literal>000000</literal> as microseconds since it takes an <type>int</type>
45
+
parameter, whereas <methodname>DateTime::format</methodname> does
46
+
support microseconds if <classname>DateTime</classname> was
47
+
created with microseconds.
48
+
</simpara>
49
+
</note>
33
50
</listitem>
34
51
</varlistentry>
35
52

...
...
@@ -41,9 +58,7 @@
41
58
<refsect1 role="returnvalues">
42
59
&reftitle.returnvalues;
43
60
<para>
44
-
Returns a formatted date string. If a non-numeric value is used for
45
-
<parameter>timestamp</parameter>, &false; is returned and an
46
-
<constant>E_WARNING</constant> level error is emitted.
61
+
Returns a formatted date string.
47
62
</para>
48
63
</refsect1>
49
64

...
...
@@ -211,6 +226,8 @@ $today = date("Y-m-d H:i:s"); // 2001-03-10 17:16:18 (the MySQ
211
226
&reftitle.seealso;
212
227
<para>
213
228
<simplelist>
229
+
<member><methodname>DateTimeImmutable::__construct</methodname></member>
230
+
<member><methodname>DateTimeInterface::format</methodname></member>
214
231
<member><function>gmdate</function></member>
215
232
<member><function>idate</function></member>
216
233
<member><function>getdate</function></member>
...
...
@@ -218,8 +235,7 @@ $today = date("Y-m-d H:i:s"); // 2001-03-10 17:16:18 (the MySQ
218
235
<member><function>mktime</function></member>
219
236
<member><methodname>IntlDateFormatter::format</methodname></member>
220
237
<member><function>time</function></member>
221
-
<member><function>DateTimeImmutable::__construct</function></member>
222
-
<member><link linkend="datetime.constants.types">Predefined DateTime Constants</link></member>
238
+
<member><link linkend="datetimeinterface.constants.types">Predefined DateTime Constants</link></member>
223
239
</simplelist>
224
240
</para>
225
241
</refsect1>
226
242