reference/datetime/functions/strftime.xml
5c951013ca04161992efed8b86fb40f55669958e
...
...
@@ -6,29 +6,41 @@
6
6
<refpurpose>Format a local time/date according to locale settings</refpurpose>
7
7
</refnamediv>
8
8

9
+
<refsynopsisdiv>
10
+
&warn.deprecated.function-8-1-0.alternatives;
11
+
<simplelist role="alternatives">
12
+
<member><function>date</function></member>
13
+
<member><methodname>IntlDateFormatter::format</methodname></member>
14
+
</simplelist>
15
+
</refsynopsisdiv>
16
+

9
17
<refsect1 role="description">
10
18
&reftitle.description;
11
19
<methodsynopsis>
12
-
<type>string</type><methodname>strftime</methodname>
20
+
<type class="union"><type>string</type><type>false</type></type><methodname>strftime</methodname>
13
21
<methodparam><type>string</type><parameter>format</parameter></methodparam>
14
-
<methodparam choice="opt"><type>int</type><parameter>timestamp</parameter><initializer>time()</initializer></methodparam>
22
+
<methodparam choice="opt"><type class="union"><type>int</type><type>null</type></type><parameter>timestamp</parameter><initializer>&null;</initializer></methodparam>
15
23
</methodsynopsis>
16
24
<para>
17
25
Format the time and/or date according to locale settings. Month and weekday
18
26
names and other language-dependent strings respect the current locale set
19
27
with <function>setlocale</function>.
20
28
</para>
21
-
<para>
22
-
Not all conversion specifiers may be supported by your C library, in which
23
-
case they will not be supported by PHP's <function>strftime</function>.
24
-
Additionally, not all platforms support negative timestamps, so your
25
-
date range may be limited to no earlier than the Unix epoch. This means that
26
-
%e, %T, %R and, %D (and possibly others) - as well as dates prior to
27
-
<literal>Jan 1, 1970</literal> - will not work on Windows, some Linux
28
-
distributions, and a few other operating systems. For Windows systems, a
29
-
complete overview of supported conversion specifiers can be found at
30
-
<link xlink:href="&url.strftime.win32;"><acronym>MSDN</acronym></link>.
31
-
</para>
29
+
<warning>
30
+
<para>
31
+
Not all conversion specifiers may be supported by your C library, in which
32
+
case they will not be supported by PHP's <function>strftime</function>.
33
+
Additionally, not all platforms support negative timestamps, so your
34
+
date range may be limited to no earlier than the Unix epoch. This means that
35
+
%e, %T, %R and, %D (and possibly others) - as well as dates prior to
36
+
<literal>Jan 1, 1970</literal> - will not work on Windows, some Linux
37
+
distributions, and a few other operating systems. For Windows systems, a
38
+
complete overview of supported conversion specifiers can be found at
39
+
<link xlink:href="&url.strftime.win32;"><acronym>MSDN</acronym></link>.
40
+
Instead use the
41
+
<methodname>IntlDateFormatter::format</methodname> method.
42
+
</para>
43
+
</warning>
32
44
</refsect1>
33
45

34
46
<refsect1 role="parameters">
...
...
@@ -208,12 +220,17 @@
208
220
<row>
209
221
<entry><literal>%p</literal></entry>
210
222
<entry>UPPER-CASE 'AM' or 'PM' based on the given time</entry>
211
-
<entry>Example: <literal>AM</literal> for 00:31, <literal>PM</literal> for 22:23</entry>
223
+
<entry>Example: <literal>AM</literal> for 00:31,
224
+
<literal>PM</literal> for 22:23. The exact result depends on the
225
+
Operating System, and they can also return lower-case variants, or
226
+
variants with dots (such as <literal>a.m.</literal>).</entry>
212
227
</row>
213
228
<row>
214
229
<entry><literal>%P</literal></entry>
215
230
<entry>lower-case 'am' or 'pm' based on the given time</entry>
216
-
<entry>Example: <literal>am</literal> for 00:31, <literal>pm</literal> for 22:23</entry>
231
+
<entry>Example: <literal>am</literal> for 00:31,
232
+
<literal>pm</literal> for 22:23. Not supported by all Operating
233
+
Systems.</entry>
217
234
</row>
218
235
<row>
219
236
<entry><literal>%r</literal></entry>
...
...
@@ -308,9 +325,6 @@
308
325
</tgroup>
309
326
</table>
310
327
</para>
311
-
<para>
312
-
Maximum length of this parameter is 1023 characters.
313
-
</para>
314
328
<warning>
315
329
<simpara>
316
330
Contrary to ISO-9899:1999, Sun Solaris starts with Sunday as 1. As a
...
...
@@ -335,7 +349,7 @@
335
349
</warning>
336
350
<warning>
337
351
<simpara>
338
-
<emphasis>macOS only:</emphasis> The <literal>%P</literal> modifier
352
+
<emphasis>macOS and musl only:</emphasis> The <literal>%P</literal> modifier
339
353
is not supported in the macOS implementation of this function.
340
354
</simpara>
341
355
</warning>
...
...
@@ -356,6 +370,9 @@
356
370
local time if no timestamp is given. Month and weekday names and
357
371
other language-dependent strings respect the current locale set
358
372
with <function>setlocale</function>.
373
+
The function returns &false; if <parameter>format</parameter> is empty, contains unsupported
374
+
conversion specifiers, or if the length of the returned string would be greater than
375
+
<literal>4095</literal>.
359
376
</para>
360
377
</refsect1>
361
378

...
...
@@ -372,6 +389,30 @@
372
389
</para>
373
390
</refsect1>
374
391

392
+
<refsect1 role="changelog">
393
+
&reftitle.changelog;
394
+
<para>
395
+
<informaltable>
396
+
<tgroup cols="2">
397
+
<thead>
398
+
<row>
399
+
<entry>&Version;</entry>
400
+
<entry>&Description;</entry>
401
+
</row>
402
+
</thead>
403
+
<tbody>
404
+
<row>
405
+
<entry>8.0.0</entry>
406
+
<entry>
407
+
<parameter>timestamp</parameter> is nullable now.
408
+
</entry>
409
+
</row>
410
+
</tbody>
411
+
</tgroup>
412
+
</informaltable>
413
+
</para>
414
+
</refsect1>
415
+

375
416
<refsect1 role="examples">
376
417
&reftitle.examples;
377
418
<para>
...
...
@@ -637,6 +678,8 @@ Unknown format : 'v'
637
678
&reftitle.seealso;
638
679
<para>
639
680
<simplelist>
681
+
<member><methodname>IntlDateFormatter::format</methodname></member>
682
+
<member><methodname>DateTimeInterface::format</methodname></member>
640
683
<member><link xlink:href="&url.strftime.format.designer;">Online strftime() format design tool</link></member>
641
684
<member><function>setlocale</function></member>
642
685
<member><function>mktime</function></member>
...
...
@@ -647,7 +690,6 @@ Unknown format : 'v'
647
690
</para>
648
691
</refsect1>
649
692
</refentry>
650
-

651
693
<!-- Keep this comment at the end of the file
652
694
Local variables:
653
695
mode: sgml
654
696