mirror of
https://github.com/php/doc-pl.git
synced 2026-03-24 07:02:07 +01:00
710 lines
30 KiB
XML
Executable File
710 lines
30 KiB
XML
Executable File
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- EN-Revision: 3a8c3e77df070a046c9d5b56b68926ca2d7e5ee3 Maintainer: sobak Status: ready -->
|
|
<!-- $Revision$ -->
|
|
<!-- CREDITS: qrak, grzesiek -->
|
|
<refentry xml:id="function.strftime" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>strftime</refname>
|
|
<refpurpose>Formatuje lokalną datę/czas zgodnie z lokalizacją</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
&warn.deprecated.function-8-1-0.alternatives;
|
|
<simplelist role="alternatives">
|
|
<member><function>date</function></member>
|
|
<member><methodname>IntlDateFormatter::format</methodname></member>
|
|
</simplelist>
|
|
</refsynopsisdiv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<modifier role="attribute">#[\Deprecated]</modifier>
|
|
<type class="union"><type>string</type><type>false</type></type><methodname>strftime</methodname>
|
|
<methodparam><type>string</type><parameter>format</parameter></methodparam>
|
|
<methodparam choice="opt"><type class="union"><type>int</type><type>null</type></type><parameter>timestamp</parameter><initializer>&null;</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Formatuje datę i lub/czas zgodnie z ustawieniami lokalizacji. Nazwy miesięcy i
|
|
i dni tygodnia oraz inne ciągi zależne od języka, przestrzegają obecnej lokalizacji
|
|
ustawionej przez <function>setlocale</function>.
|
|
</para>
|
|
<warning>
|
|
<para>
|
|
Nie wszystkie symbole konwersji mogą być wspierane przez Twoją bibliotekę C i w takim
|
|
wypadku nie będą wspierane przez funkcję <function>strftime</function> z PHP.
|
|
Ponadto, nie wszystkie platformy wspierają ujemne zaczniki czasu, więc zakres
|
|
dat może być ograniczony do początku epoki Uniksa. Oznacza to, że
|
|
%e, %T, %R i %D (oraz możliwe, że inne) - tak samo jak daty przed
|
|
<literal>01.01.1970</literal> - to wszystko nie zadziała na Windows, niektórych
|
|
dystrybucjach Linuksa i kilku innych systemach operacyjnych. Przegląd symboli
|
|
konwersji wspieranych przez system Windows można znaleźć na
|
|
<link xlink:href="&url.strftime.win32;"><acronym>MSDN</acronym></link>.
|
|
</para>
|
|
</warning>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>format</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
<table>
|
|
<title>Symbole rozpoznawane w treści argumentu
|
|
<parameter>format</parameter></title>
|
|
<tgroup cols="3">
|
|
<thead>
|
|
<row>
|
|
<entry><parameter>format</parameter></entry>
|
|
<entry>Opis</entry>
|
|
<entry>Przykład zwróconej wartości</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry align="center"><emphasis>Dzień</emphasis></entry>
|
|
<entry>---</entry>
|
|
<entry>---</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%a</literal></entry>
|
|
<entry>Skrótowa tekstowa nazwa dnia</entry>
|
|
<entry><literal>Sun</literal> do <literal>Sat</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%A</literal></entry>
|
|
<entry>Pełna tekstowa nazwa dnia</entry>
|
|
<entry><literal>Sunday</literal> do <literal>Saturday</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%d</literal></entry>
|
|
<entry>Dwucyfrowy zapis dnia miesiąca (z zerami wiodącymi)</entry>
|
|
<entry><literal>01</literal> do <literal>31</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%e</literal></entry>
|
|
<entry>
|
|
Dzień miesiąca ze spacją poprzedzającą wartości jednocyfrowe. Niedostępne
|
|
w systemie Windows, jak już napisano. Więcej informacji znajdziesz poniżej.
|
|
</entry>
|
|
<entry><literal> 1</literal> do <literal>31</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%j</literal></entry>
|
|
<entry>Dzień roku, 3 cyfry z zerami wiodącymi</entry>
|
|
<entry><literal>001</literal> do <literal>366</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%u</literal></entry>
|
|
<entry>Numeryczne przedstawienie dnia tygodnia zgodne z ISO-8601</entry>
|
|
<entry><literal>1</literal> (poniedziałek) do <literal>7</literal> (niedziela)</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%w</literal></entry>
|
|
<entry>Numeryczne przedstawienie dnia tygodnia</entry>
|
|
<entry><literal>0</literal> (niedziela) do <literal>6</literal> (sobota)</entry>
|
|
</row>
|
|
<row>
|
|
<entry align="center"><emphasis>Tydzień</emphasis></entry>
|
|
<entry>---</entry>
|
|
<entry>---</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%U</literal></entry>
|
|
<entry>Numer tygodnia w danym roku, poczynając od pierwszej niedzieli,
|
|
jako pierwszego tygodnia</entry>
|
|
<entry><literal>13</literal> (dla trzynastego tygodnia w roku)</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%V</literal></entry>
|
|
<entry>Numer tygonia w danym roku zgodny z ISO-8601:1988, poczynając od
|
|
pierwszego tygodnia, z przynajmniej czterema dniami w tym roku, poniedziałek
|
|
jest początkiem tygodnia</entry>
|
|
<entry><literal>01</literal> do <literal>53</literal> (gdzie 53
|
|
to tydzień przejściowy)</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%W</literal></entry>
|
|
<entry>Numer tygodnia w danym roku, poczynając od
|
|
pierwszego poniedziałku, jako pierwszego tygodnia</entry>
|
|
<entry><literal>46</literal> (dla 46 tygodnia roku rozpoczynającego
|
|
się poniedziałkiem)</entry>
|
|
</row>
|
|
<row>
|
|
<entry align="center"><emphasis>Miesiąc</emphasis></entry>
|
|
<entry>---</entry>
|
|
<entry>---</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%b</literal></entry>
|
|
<entry>Skrótowa nazwa miesiąca, zgodnie z lokalizacją</entry>
|
|
<entry><literal>Sty</literal> do <literal>Gru</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%B</literal></entry>
|
|
<entry>Pełna nazwa miesiąca, zgodnie z lokalizacją</entry>
|
|
<entry><literal>Styczeń</literal> do <literal>Grudzień</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%h</literal></entry>
|
|
<entry>Skrótowa nazwa miesiąca, zgodnie z lokalizacją (alias dla %b)</entry>
|
|
<entry><literal>Sty</literal> do <literal>Gru</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%m</literal></entry>
|
|
<entry>Dwucyfrowa reprezentacja miesiąca</entry>
|
|
<entry><literal>01</literal> (styczeń) do <literal>12</literal> (grudzień)</entry>
|
|
</row>
|
|
<row>
|
|
<entry align="center"><emphasis>Rok</emphasis></entry>
|
|
<entry>---</entry>
|
|
<entry>---</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%C</literal></entry>
|
|
<entry>Dwucyfrowa reprezentacja stulecia (rok podzielony na 100, przycięty do liczby całkowitej)</entry>
|
|
<entry><literal>19</literal> dla dwudziestego wieku</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%g</literal></entry>
|
|
<entry>Dwucyfrowa reprezentacja roku zgodna ze standardem ISO-8601:1988 (zobacz %V)</entry>
|
|
<entry>Przykład: <literal>09</literal> dla tygodnia z 06.01.2009</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%G</literal></entry>
|
|
<entry>Pełna, czterocyfrowa wersja %g</entry>
|
|
<entry>Przykład: <literal>2008</literal> dla tygodnia z 03.01.2009</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%y</literal></entry>
|
|
<entry>Dwucyfrowa reprezentacja roku</entry>
|
|
<entry>Przykład: <literal>09</literal> dla roku 2009, <literal>79</literal> dla roku 1979</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%Y</literal></entry>
|
|
<entry>Czterocyfrowa reprezentacja roku</entry>
|
|
<entry>Przykład: <literal>2038</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry align="center"><emphasis>Czas</emphasis></entry>
|
|
<entry>---</entry>
|
|
<entry>---</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%H</literal></entry>
|
|
<entry>Dwucyfrowa reprezentacja godziny, w formacie 24-godzinnym</entry>
|
|
<entry><literal>00</literal> do <literal>23</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%k</literal></entry>
|
|
<entry>Godzina w formacie 24-godzinnym, ze spacją poprzedzającą wartości jednocyfrowe</entry>
|
|
<entry><literal> 0</literal> do <literal>23</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%I</literal></entry>
|
|
<entry>Dwucyfrowa reprezentacja godziny, w formacie 12-godzinnym</entry>
|
|
<entry><literal>01</literal> do <literal>12</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%l (małe 'L')</literal></entry>
|
|
<entry>Dwucyfrowa reprezentacja godziny, w formacie 12-godzinnym, ze spacją
|
|
poprzedzającą wartości jednocyfrowe</entry>
|
|
<entry><literal> 1</literal> do <literal>12</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%M</literal></entry>
|
|
<entry>Dwucyfrowa reprezentacja minuty</entry>
|
|
<entry><literal>00</literal> do <literal>59</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%p</literal></entry>
|
|
<entry>'AM' lub 'PM' zapisane wielkimi literami, zależnie od podanego czasu</entry>
|
|
<entry>Przykład: <literal>AM</literal> dla 00:31,
|
|
<literal>PM</literal> dla 22:23. Dokładny wynik zależy od
|
|
systemu operacyjnego, może zostać zwrócony zapis małymi literami lub
|
|
zapis z kropkami (tj. <literal>a.m.</literal>)</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%P</literal></entry>
|
|
<entry>'am' lub 'pm' zapisane malymi literami, zależnie od podanego czasu</entry>
|
|
<entry>Przykład: <literal>am</literal> dla 00:31,
|
|
<literal>pm</literal> dla 22:23. Nie jest wspierane przez wszystkie systemy
|
|
operacyjne.</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%r</literal></entry>
|
|
<entry>To samo co "%I:%M:%S %p"</entry>
|
|
<entry>Przykład: <literal>09:34:17 PM</literal> dla 21:34:17</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%R</literal></entry>
|
|
<entry>To samo co "%H:%M"</entry>
|
|
<entry>Przykład: <literal>00:35</literal> dla 12:35 AM, <literal>16:44</literal> dla 4:44 PM</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%S</literal></entry>
|
|
<entry>Dwucyfrowa reprezentacja sekundy</entry>
|
|
<entry><literal>00</literal> do <literal>59</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%T</literal></entry>
|
|
<entry>To samo co "%H:%M:%S"</entry>
|
|
<entry>Przykład: <literal>21:34:17</literal> dla 09:34:17 PM</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%X</literal></entry>
|
|
<entry>Preferowane przedstawienie czasu, zależne od lokalizacji, bez daty</entry>
|
|
<entry>Przykład: <literal>03:59:16</literal> lub <literal>15:59:16</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%z</literal></entry>
|
|
<entry>Przesunięcie strefy czasowej. Niedostępne na Windows,
|
|
jak już napisano. Więcej informacji znajdziesz poniżej.</entry>
|
|
<entry>Przykład: <literal>-0500</literal> dla czasu w US Eastern Time</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%Z</literal></entry>
|
|
<entry>Skrót strefy czasowej. Niedostępne na Windows,
|
|
jak już napisano. Więcej informacji znajdziesz poniżej.</entry>
|
|
<entry>Przykład: <literal>EST</literal> dla czasu w Eastern Time</entry>
|
|
</row>
|
|
<row>
|
|
<entry align="center"><emphasis>Znaczniki daty i czasu</emphasis></entry>
|
|
<entry>---</entry>
|
|
<entry>---</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%c</literal></entry>
|
|
<entry>Preferowany znacznik daty i czasu w obecnej lokalizacji</entry>
|
|
<entry>Przykład: <literal>Pon 05.02.2009 00:45:10</literal> dla
|
|
February 5, 2009 at 12:45:10 AM</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%D</literal></entry>
|
|
<entry>To samo co "%m/%d/%y"</entry>
|
|
<entry>Przykład: <literal>02/05/09</literal> dla 02.05.2009</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%F</literal></entry>
|
|
<entry>To samo co "%Y-%m-%d" (często używane w znacznikach dat baz danych)</entry>
|
|
<entry>Przykład: <literal>2009-02-05</literal> dla 02.05.2009</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%s</literal></entry>
|
|
<entry>Uniksowy znacznik czasu (to samo co funkcja <function>time</function>)</entry>
|
|
<entry>Przykład: <literal>305815200</literal> dla 10.09.1979 08:40:00</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%x</literal></entry>
|
|
<entry>Preferowana reprezentacja daty w obecej lokalizacji, bez czasu</entry>
|
|
<entry>Przykład: <literal>02/05/09</literal> dla 05.02.2009</entry>
|
|
</row>
|
|
<row>
|
|
<entry align="center"><emphasis>Różne</emphasis></entry>
|
|
<entry>---</entry>
|
|
<entry>---</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%n</literal></entry>
|
|
<entry>Znak nowej linii ("\n")</entry>
|
|
<entry>---</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%t</literal></entry>
|
|
<entry>Tabulator ("\t")</entry>
|
|
<entry>---</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%%</literal></entry>
|
|
<entry>Znak procenta ("%")</entry>
|
|
<entry>---</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</para>
|
|
<warning>
|
|
<simpara>
|
|
W przeciwieństwie do ISO-9899:1999, system Sun Solaris podaje niedzielę jako 1. W wyniku
|
|
tego, <literal>%u</literal> może nie działać tak jak opisano to w tym
|
|
podręczniku.
|
|
</simpara>
|
|
</warning>
|
|
<warning>
|
|
<para>
|
|
<emphasis>Tylko dla Windows:</emphasis>
|
|
</para>
|
|
<para>
|
|
Modyfikator <literal>%e</literal> nie jest wspierany w Windowsowej
|
|
implementatacji tej funkcji. Aby otrzymać tą wartość, można użyć
|
|
modyfikatora <literal>%#d</literal>. Przykład poniżej
|
|
pokazuje jak napisać funkcję kompatybilną między platformami.
|
|
</para>
|
|
<para>
|
|
Modyfikatory <literal>%z</literal> i <literal>%Z</literal> zwracają
|
|
nazę strefy czasowej zamiast jej przesunięcia czy skrótu.
|
|
</para>
|
|
</warning>
|
|
<warning>
|
|
<simpara>
|
|
<emphasis>Tylko dla macOS i musl:</emphasis> Modyfikator <literal>%P</literal> nie jest
|
|
wspierany w implementacji tej funkcji dla macOS.
|
|
</simpara>
|
|
</warning>
|
|
</listitem>
|
|
</varlistentry>
|
|
|
|
&date.timestamp.description;
|
|
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Zwraca łańcuch znaków sformatowany zgodnie z argumentem <parameter>format</parameter>
|
|
używając czasu podanego jako <parameter>timestamp</parameter> lub obecnego
|
|
czasu lokalnego, jeśli nie podano tego argumentu. Nazwy miesięcy i dni tygodnia oraz
|
|
inne ciągi znaków zależne od języka uwzględniają obecną lokalizację ustawioną
|
|
przez <function>setlocale</function>.
|
|
Funkcja zwraca &false; jeśli <parameter>format</parameter> jest pusty, zawiera niewspierane
|
|
modyfikatory konwersji lub jeśli zwrócony ciąg znaków byłby dłuższy niż
|
|
<literal>4095</literal> znaków.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="errors">
|
|
&reftitle.errors;
|
|
&date.timezone.errors.description;
|
|
<para>
|
|
Ponieważ wynik funkcji zależy od działającej pod spodem biblioteki C, niektóre modyfikatory
|
|
nie są wspierane. Na Windows, podanie nieznanego modyfikatora zaskutkuje
|
|
wygenerowaniem 5 wiadomości <constant>E_WARNING</constant> i zwróceniem
|
|
&false;. Na innych systemach możesz nie otrzymać żadnych wiadomości
|
|
<constant>E_WARNING</constant>, a wyjście może zawierać
|
|
nieskonwertowane modyfikatory.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<para>
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>8.0.0</entry>
|
|
<entry>
|
|
Parametr <parameter>timestamp</parameter> dopuszcza teraz &null;.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
Ten przykład zadziała, jeżeli masz zainstalowane w systemie odpowiednie
|
|
lokalizacje.
|
|
<example>
|
|
<title>Przykłady lokalizacji <function>strftime</function></title>
|
|
<programlisting role="php" annotations="non-interactive">
|
|
<![CDATA[
|
|
<?php
|
|
setlocale(LC_TIME, "C");
|
|
echo strftime("%A");
|
|
setlocale(LC_TIME, "fi_FI");
|
|
echo strftime(" po fińsku to %A,");
|
|
setlocale(LC_TIME, "fr_FR");
|
|
echo strftime(" po francusku %A i");
|
|
setlocale(LC_TIME, "de_DE");
|
|
echo strftime(" po niemiecku %A.\n");
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Przykład numerów tygodnia zgodnych z ISO 8601:1988</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
/* Grudzień 2002 / Styczeń 2003
|
|
ISOTyg Po Wt Śr Czw Pt So Nd
|
|
----- ----------------------------
|
|
51 16 17 18 19 20 21 22
|
|
52 23 24 25 26 27 28 29
|
|
1 30 31 1 2 3 4 5
|
|
2 6 7 8 9 10 11 12
|
|
3 13 14 15 16 17 18 19 */
|
|
|
|
// Wyświetla: 12/28/2002 - %V,%G,%Y = 52,2002,2002
|
|
echo "12/28/2002 - %V,%G,%Y = " . strftime("%V,%G,%Y", strtotime("12/28/2002")) . "\n";
|
|
|
|
// Wyświetla: 12/30/2002 - %V,%G,%Y = 1,2003,2002
|
|
echo "12/30/2002 - %V,%G,%Y = " . strftime("%V,%G,%Y", strtotime("12/30/2002")) . "\n";
|
|
|
|
// Wyświetla: 1/3/2003 - %V,%G,%Y = 1,2003,2003
|
|
echo "1/3/2003 - %V,%G,%Y = " . strftime("%V,%G,%Y",strtotime("1/3/2003")) . "\n";
|
|
|
|
// Wyświetla: 1/10/2003 - %V,%G,%Y = 2,2003,2003
|
|
echo "1/10/2003 - %V,%G,%Y = " . strftime("%V,%G,%Y",strtotime("1/10/2003")) . "\n";
|
|
|
|
|
|
|
|
/* Grudzień 2004 / Styczeń 2005
|
|
ISOTyg Po Wt Śr Czw Pt So Nd
|
|
----- ----------------------------
|
|
51 13 14 15 16 17 18 19
|
|
52 20 21 22 23 24 25 26
|
|
53 27 28 29 30 31 1 2
|
|
1 3 4 5 6 7 8 9
|
|
2 10 11 12 13 14 15 16 */
|
|
|
|
// Wyświetla: 12/23/2004 - %V,%G,%Y = 52,2004,2004
|
|
echo "12/23/2004 - %V,%G,%Y = " . strftime("%V,%G,%Y",strtotime("12/23/2004")) . "\n";
|
|
|
|
// Wyświetla: 12/31/2004 - %V,%G,%Y = 53,2004,2004
|
|
echo "12/31/2004 - %V,%G,%Y = " . strftime("%V,%G,%Y",strtotime("12/31/2004")) . "\n";
|
|
|
|
// Wyświetla: 1/2/2005 - %V,%G,%Y = 53,2004,2005
|
|
echo "1/2/2005 - %V,%G,%Y = " . strftime("%V,%G,%Y",strtotime("1/2/2005")) . "\n";
|
|
|
|
// Wyświetla: 1/3/2005 - %V,%G,%Y = 1,2005,2005
|
|
echo "1/3/2005 - %V,%G,%Y = " . strftime("%V,%G,%Y",strtotime("1/3/2005")) . "\n";
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Przykład wieloplatformowego użycia modyfikatora <literal>%e</literal></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
// 1 stycznia: wynikiem jest: '%e%1%' (%%, e, %%, %e, %%)
|
|
$format = '%%e%%%e%%';
|
|
|
|
// Zajdź i zamień modyfikator %e
|
|
// pod Windows
|
|
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
|
|
$format = preg_replace('#(?<!%)((?:%%)*)%e#', '\1%#d', $format);
|
|
}
|
|
|
|
echo strftime($format);
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Wyświetl wszystkie znane i nieznane formaty</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
// Opis formatów
|
|
$strftimeFormats = array(
|
|
'A' => 'A full textual representation of the day',
|
|
'B' => 'Full month name, based on the locale',
|
|
'C' => 'Two digit representation of the century (year divided by 100, truncated to an integer)',
|
|
'D' => 'Same as "%m/%d/%y"',
|
|
'E' => '',
|
|
'F' => 'Same as "%Y-%m-%d"',
|
|
'G' => 'The full four-digit version of %g',
|
|
'H' => 'Two digit representation of the hour in 24-hour format',
|
|
'I' => 'Two digit representation of the hour in 12-hour format',
|
|
'J' => '',
|
|
'K' => '',
|
|
'L' => '',
|
|
'M' => 'Two digit representation of the minute',
|
|
'N' => '',
|
|
'O' => '',
|
|
'P' => 'lower-case "am" or "pm" based on the given time',
|
|
'Q' => '',
|
|
'R' => 'Same as "%H:%M"',
|
|
'S' => 'Two digit representation of the second',
|
|
'T' => 'Same as "%H:%M:%S"',
|
|
'U' => 'Week number of the given year, starting with the first Sunday as the first week',
|
|
'V' => 'ISO-8601:1988 week number of the given year, starting with the first week of the year with at least 4 weekdays, with Monday being the start of the week',
|
|
'W' => 'A numeric representation of the week of the year, starting with the first Monday as the first week',
|
|
'X' => 'Preferred time representation based on locale, without the date',
|
|
'Y' => 'Four digit representation for the year',
|
|
'Z' => 'The time zone offset/abbreviation option NOT given by %z (depends on operating system)',
|
|
'a' => 'An abbreviated textual representation of the day',
|
|
'b' => 'Abbreviated month name, based on the locale',
|
|
'c' => 'Preferred date and time stamp based on local',
|
|
'd' => 'Two-digit day of the month (with leading zeros)',
|
|
'e' => 'Day of the month, with a space preceding single digits',
|
|
'f' => '',
|
|
'g' => 'Two digit representation of the year going by ISO-8601:1988 standards (see %V)',
|
|
'h' => 'Abbreviated month name, based on the locale (an alias of %b)',
|
|
'i' => '',
|
|
'j' => 'Day of the year, 3 digits with leading zeros',
|
|
'k' => 'Hour in 24-hour format, with a space preceding single digits',
|
|
'l' => 'Hour in 12-hour format, with a space preceding single digits',
|
|
'm' => 'Two digit representation of the month',
|
|
'n' => 'A newline character ("\n")',
|
|
'o' => '',
|
|
'p' => 'UPPER-CASE "AM" or "PM" based on the given time',
|
|
'q' => '',
|
|
'r' => 'Same as "%I:%M:%S %p"',
|
|
's' => 'Unix Epoch Time timestamp',
|
|
't' => 'A Tab character ("\t")',
|
|
'u' => 'ISO-8601 numeric representation of the day of the week',
|
|
'v' => '',
|
|
'w' => 'Numeric representation of the day of the week',
|
|
'x' => 'Preferred date representation based on locale, without the time',
|
|
'y' => 'Two digit representation of the year',
|
|
'z' => 'Either the time zone offset from UTC or the abbreviation (depends on operating system)',
|
|
'%' => 'A literal percentage character ("%")',
|
|
);
|
|
|
|
// Results
|
|
$strftimeValues = array();
|
|
|
|
// Evaluate the formats whilst suppressing any errors
|
|
foreach ($strftimeFormats as $format => $description) {
|
|
if (False !== ($value = @strftime("%{$format}"))) {
|
|
$strftimeValues[$format] = $value;
|
|
}
|
|
}
|
|
|
|
// Find the longest value
|
|
$maxValueLength = 2 + max(array_map('strlen', $strftimeValues));
|
|
|
|
// Report known formats
|
|
foreach ($strftimeValues as $format => $value) {
|
|
echo "Known format : '{$format}' = ", str_pad("'{$value}'", $maxValueLength), " ( {$strftimeFormats[$format]} )\n";
|
|
}
|
|
|
|
// Report unknown formats
|
|
foreach (array_diff_key($strftimeFormats, $strftimeValues) as $format => $description) {
|
|
echo "Unknown format : '{$format}' ", str_pad(' ', $maxValueLength), ($description ? " ( {$description} )" : ''), "\n";
|
|
}
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs.similar;
|
|
<screen>
|
|
<![CDATA[
|
|
Known format : 'A' = 'Friday' ( A full textual representation of the day )
|
|
Known format : 'B' = 'December' ( Full month name, based on the locale )
|
|
Known format : 'H' = '11' ( Two digit representation of the hour in 24-hour format )
|
|
Known format : 'I' = '11' ( Two digit representation of the hour in 12-hour format )
|
|
Known format : 'M' = '24' ( Two digit representation of the minute )
|
|
Known format : 'S' = '44' ( Two digit representation of the second )
|
|
Known format : 'U' = '48' ( Week number of the given year, starting with the first Sunday as the first week )
|
|
Known format : 'W' = '48' ( A numeric representation of the week of the year, starting with the first Monday as the first week )
|
|
Known format : 'X' = '11:24:44' ( Preferred time representation based on locale, without the date )
|
|
Known format : 'Y' = '2010' ( Four digit representation for the year )
|
|
Known format : 'Z' = 'GMT Standard Time' ( The time zone offset/abbreviation option NOT given by %z (depends on operating system) )
|
|
Known format : 'a' = 'Fri' ( An abbreviated textual representation of the day )
|
|
Known format : 'b' = 'Dec' ( Abbreviated month name, based on the locale )
|
|
Known format : 'c' = '12/03/10 11:24:44' ( Preferred date and time stamp based on local )
|
|
Known format : 'd' = '03' ( Two-digit day of the month (with leading zeros) )
|
|
Known format : 'j' = '337' ( Day of the year, 3 digits with leading zeros )
|
|
Known format : 'm' = '12' ( Two digit representation of the month )
|
|
Known format : 'p' = 'AM' ( UPPER-CASE "AM" or "PM" based on the given time )
|
|
Known format : 'w' = '5' ( Numeric representation of the day of the week )
|
|
Known format : 'x' = '12/03/10' ( Preferred date representation based on locale, without the time )
|
|
Known format : 'y' = '10' ( Two digit representation of the year )
|
|
Known format : 'z' = 'GMT Standard Time' ( Either the time zone offset from UTC or the abbreviation (depends on operating system) )
|
|
Known format : '%' = '%' ( A literal percentage character ("%") )
|
|
Unknown format : 'C' ( Two digit representation of the century (year divided by 100, truncated to an integer) )
|
|
Unknown format : 'D' ( Same as "%m/%d/%y" )
|
|
Unknown format : 'E'
|
|
Unknown format : 'F' ( Same as "%Y-%m-%d" )
|
|
Unknown format : 'G' ( The full four-digit version of %g )
|
|
Unknown format : 'J'
|
|
Unknown format : 'K'
|
|
Unknown format : 'L'
|
|
Unknown format : 'N'
|
|
Unknown format : 'O'
|
|
Unknown format : 'P' ( lower-case "am" or "pm" based on the given time )
|
|
Unknown format : 'Q'
|
|
Unknown format : 'R' ( Same as "%H:%M" )
|
|
Unknown format : 'T' ( Same as "%H:%M:%S" )
|
|
Unknown format : 'V' ( ISO-8601:1988 week number of the given year, starting with the first week of the year with at least 4 weekdays, with Monday being the start of the week )
|
|
Unknown format : 'e' ( Day of the month, with a space preceding single digits )
|
|
Unknown format : 'f'
|
|
Unknown format : 'g' ( Two digit representation of the year going by ISO-8601:1988 standards (see %V) )
|
|
Unknown format : 'h' ( Abbreviated month name, based on the locale (an alias of %b) )
|
|
Unknown format : 'i'
|
|
Unknown format : 'k' ( Hour in 24-hour format, with a space preceding single digits )
|
|
Unknown format : 'l' ( Hour in 12-hour format, with a space preceding single digits )
|
|
Unknown format : 'n' ( A newline character ("\n") )
|
|
Unknown format : 'o'
|
|
Unknown format : 'q'
|
|
Unknown format : 'r' ( Same as "%I:%M:%S %p" )
|
|
Unknown format : 's' ( Unix Epoch Time timestamp )
|
|
Unknown format : 't' ( A Tab character ("\t") )
|
|
Unknown format : 'u' ( ISO-8601 numeric representation of the day of the week )
|
|
Unknown format : 'v'
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
<note>
|
|
<simpara>
|
|
%G i %V, które bazują na numerach tygodni ISO 8601:1988, mogą zwrócić
|
|
nieprzewidziane (choć poprawne) wyniki jeżeli system numeracji nie został
|
|
dogłębnie zrozumiany. Zobacz przykłady dla %V na tej stronie podręcznika.
|
|
</simpara>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><methodname>IntlDateFormatter::format</methodname></member>
|
|
<member><methodname>DateTimeInterface::format</methodname></member>
|
|
<member><link xlink:href="&url.strftime.format.designer;">Narzędzie online do tworzenia formatów strftime()</link></member>
|
|
<member><function>setlocale</function></member>
|
|
<member><function>mktime</function></member>
|
|
<member><function>strptime</function></member>
|
|
<member><function>gmstrftime</function></member>
|
|
<member><link xlink:href="&spec.strftime;">Specyfikacja Open Group dla <function>strftime</function></link></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|