mirror of
https://github.com/php/doc-pt_br.git
synced 2026-03-24 07:02:09 +01:00
710 lines
30 KiB
XML
710 lines
30 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!-- EN-Revision: 3a8c3e77df070a046c9d5b56b68926ca2d7e5ee3 Maintainer: leonardolara Status: ready --><!-- CREDITS: felipe, surfmax, fabioluciano, leonardolara -->
|
|
<refentry xml:id="function.strftime" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>strftime</refname>
|
|
<refpurpose>Formata uma data/horário de acordo com as configurações locais</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>
|
|
Formata uma data/horário local de acordo com a configuração do idioma. Nome do mês
|
|
e dia da semana e outras strings respeitam o idioma corrente definido
|
|
com a função <function>setlocale</function>.
|
|
</para>
|
|
<warning>
|
|
<para>
|
|
Nem todos os especificadores de conversão podem ser suportados por suas bibliotecas C, e nestes
|
|
casos eles não serão suportados pela função do PHP <function>strftime</function>.
|
|
Além disso, nem todas as plataformas suportam timestamps negativos, então sua
|
|
faixa de datas pode ficar limitada a um valor não anterior à época Unix. Isto significa que
|
|
%e, %T, %R e %D (e possivelmente outras) - assim como datas anteriores a
|
|
<literal>1 de janeiro de 1970</literal> - não funcionarão no Windows, algumas distribuições
|
|
Linux, e alguns outros sistemas operacionais. Para sistemas Windows, uma visão
|
|
completa dos especificadores de conversão suportados podem ser encontrados em
|
|
<link xlink:href="&url.strftime.win32;"><acronym>MSDN</acronym></link>.
|
|
No lugar desta função, use
|
|
o método <methodname>IntlDateFormatter::format</methodname>.
|
|
</para>
|
|
</warning>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>format</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
<table>
|
|
<title>Os seguintes caracteres são reconhecidos na string do
|
|
parâmetro <parameter>format</parameter></title>
|
|
<tgroup cols="3">
|
|
<thead>
|
|
<row>
|
|
<entry><parameter>format</parameter></entry>
|
|
<entry>Descrição</entry>
|
|
<entry>Exemplo de valores retornados</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry align="center"><emphasis>Dia</emphasis></entry>
|
|
<entry>---</entry>
|
|
<entry>---</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%a</literal></entry>
|
|
<entry>Representação textual abreviada do dia</entry>
|
|
<entry><literal>Sun</literal> até <literal>Sat</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%A</literal></entry>
|
|
<entry>Representação textual completa do dia</entry>
|
|
<entry><literal>Sunday</literal> até <literal>Saturday</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%d</literal></entry>
|
|
<entry>Dia do mês, com dois dígitos (com zeros à esquerda)</entry>
|
|
<entry><literal>01</literal> a <literal>31</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%e</literal></entry>
|
|
<entry>
|
|
Dia do mês com um dígito, precedido com um espaço. Não
|
|
implementado como descrito no Windows. Veja abaixo para mais informações.
|
|
</entry>
|
|
<entry><literal> 1</literal> a <literal>31</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%j</literal></entry>
|
|
<entry>Dia do ano, com 3 dígitos e zeros à esquerda</entry>
|
|
<entry><literal>001</literal> a <literal>366</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%u</literal></entry>
|
|
<entry>Representação numérica, do dia da semana, compatível com a ISO-8601</entry>
|
|
<entry><literal>1</literal> (para segunda-feira) até <literal>7</literal> (para domingo)</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%w</literal></entry>
|
|
<entry>Representação numérica do dia da semana</entry>
|
|
<entry><literal>0</literal> (para domingo) até <literal>6</literal> (para sábado)</entry>
|
|
</row>
|
|
<row>
|
|
<entry align="center"><emphasis>Semana</emphasis></entry>
|
|
<entry>---</entry>
|
|
<entry>---</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%U</literal></entry>
|
|
<entry>Número da semana de um dado ano, iniciado com o primeiro
|
|
domingo sendo a primeira semana</entry>
|
|
<entry><literal>13</literal> (como a 13ª semana completa do ano)</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%V</literal></entry>
|
|
<entry>Número da semana, compatível com a ISO-8601:1988 de um dado ano, iniciada com
|
|
a primeira semana do ano com pelo menos 4 finais de semana, sendo a segunda-feira
|
|
como o início da semana.</entry>
|
|
<entry><literal>01</literal> até <literal>53</literal> (onde 53
|
|
é responsável por uma sobreposição)</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%W</literal></entry>
|
|
<entry>Representação numérica da semana do ano, começando
|
|
pela primeira segunda-feira como primeira semana</entry>
|
|
<entry><literal>46</literal> (como a 46ª semana do do ano iniciando
|
|
na segunda-feira)</entry>
|
|
</row>
|
|
<row>
|
|
<entry align="center"><emphasis>Mês</emphasis></entry>
|
|
<entry>---</entry>
|
|
<entry>---</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%b</literal></entry>
|
|
<entry>Nome do mês abreviado, baseado no idioma</entry>
|
|
<entry><literal>jan</literal> até <literal>dez</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%B</literal></entry>
|
|
<entry>Nome completo do mês, baseado no idioma</entry>
|
|
<entry><literal>janeiro</literal> até <literal>dezembro</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%h</literal></entry>
|
|
<entry>Nome do mês abreviado, baseado no idioma (sinônimo de %b)</entry>
|
|
<entry><literal>jan</literal> até <literal>dez</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%m</literal></entry>
|
|
<entry>Representação com dois dígitos do mês</entry>
|
|
<entry><literal>01</literal> (para janeiro) até <literal>12</literal> (para dezembro)</entry>
|
|
</row>
|
|
<row>
|
|
<entry align="center"><emphasis>Ano</emphasis></entry>
|
|
<entry>---</entry>
|
|
<entry>---</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%C</literal></entry>
|
|
<entry>Representação, com dois dígitos, do século (ano dividido por 100, truncado como inteiro)</entry>
|
|
<entry><literal>19</literal> para o século 20</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%g</literal></entry>
|
|
<entry>Representação do ano, com dois dígitos, seguindo o padrão ISO-8601:1988 (veja %V)</entry>
|
|
<entry>Exemplo: <literal>09</literal> de 6 de janeiro de 2009</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%G</literal></entry>
|
|
<entry>Versão de 4 dígitos de %g</entry>
|
|
<entry>Exemplo: <literal>2008</literal> de 3 de janeiro de 2009</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%y</literal></entry>
|
|
<entry>Representação, com dois dígitos, do ano</entry>
|
|
<entry>Exemplo: <literal>09</literal> de 2009, <literal>79</literal> de 1979</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%Y</literal></entry>
|
|
<entry>Representação, com quatro dígitos, do ano</entry>
|
|
<entry>Exemplo: <literal>2038</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry align="center"><emphasis>Hora</emphasis></entry>
|
|
<entry>---</entry>
|
|
<entry>---</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%H</literal></entry>
|
|
<entry>Representação, com dois dígitos, da hora no formato 24 horas</entry>
|
|
<entry><literal>00</literal> até <literal>23</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%k</literal></entry>
|
|
<entry>Representação da hora no formato 24 horas, com um espaço precedendo dígito único</entry>
|
|
<entry><literal> 0</literal> até <literal>23</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%I</literal></entry>
|
|
<entry>Representação, com dois dígitos, da hora no formato 12 horas</entry>
|
|
<entry><literal>01</literal> até <literal>12</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%l ('L' minúsculo)</literal></entry>
|
|
<entry>Representação da hora no formato 12 horas, com um espaço precedendo dígito único</entry>
|
|
<entry><literal> 1</literal> até <literal>12</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%M</literal></entry>
|
|
<entry>Representação, com dois dígitos, do minuto</entry>
|
|
<entry><literal>00</literal> até <literal>59</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%p</literal></entry>
|
|
<entry>'AM' ou 'PM' maiúsculo baseado na hora informada</entry>
|
|
<entry>Exemplo: <literal>AM</literal> para 00:31,
|
|
<literal>PM</literal> para 22:23. O resultado exato depende do
|
|
sistema operacional, e pode retornar variantes em minúsculoas, ou
|
|
variantes com pontos (como <literal>a.m.</literal>).</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%P</literal></entry>
|
|
<entry>'am' ou 'pm' maiúsculo baseado na hora informada</entry>
|
|
<entry>Exemplo: <literal>am</literal> para 00:31,
|
|
<literal>pm</literal> para 22:23. Não suportado por todos os sistemas
|
|
operacionais.</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%r</literal></entry>
|
|
<entry>O mesmo que "%I:%M:%S %p"</entry>
|
|
<entry>Exemplo: <literal>09:34:17 PM</literal> de 21:34:17</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%R</literal></entry>
|
|
<entry>O mesmo que "%H:%M"</entry>
|
|
<entry>Exemplo: <literal>00:35</literal> de 12:35 AM, <literal>16:44</literal> de 4:44 PM</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%S</literal></entry>
|
|
<entry>Representação, com dois dígitos, do segundo</entry>
|
|
<entry><literal>00</literal> até <literal>59</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%T</literal></entry>
|
|
<entry>O mesmo que "%H:%M:%S"</entry>
|
|
<entry>Exemplo: <literal>21:34:17</literal> para 09:34:17 PM</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%X</literal></entry>
|
|
<entry>Representação escolhida baseada no idioma, sem a data</entry>
|
|
<entry>Exemplo: <literal>03:59:16</literal> ou <literal>15:59:16</literal></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%z</literal></entry>
|
|
<entry>O deslocamento do fuso horário. Não implementado como descrito no
|
|
Windows. Veja mais informações a seguir.</entry>
|
|
<entry>Exemplo: <literal>-0500</literal> para hora à leste dos EUA</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%Z</literal></entry>
|
|
<entry>A abreviação do fuso horário. Não implementado como descrito no
|
|
Windows. Veja mais informações a seguir.</entry>
|
|
<entry>Exemplo: <literal>EST</literal> para Eastern Time</entry>
|
|
</row>
|
|
<row>
|
|
<entry align="center"><emphasis>Carimbos de Data e Hora</emphasis></entry>
|
|
<entry>---</entry>
|
|
<entry>---</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%c</literal></entry>
|
|
<entry>Carimbo escolhido de data e hora baseado no idioma</entry>
|
|
<entry>Exemplo: <literal>Ter Fev 5 00:45:10 2009</literal> de
|
|
February 5, 2009 at 12:45:10 AM</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%D</literal></entry>
|
|
<entry>O mesmo que "%m/%d/%y"</entry>
|
|
<entry>Exemplo: <literal>02/05/09</literal> de February 5, 2009</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%F</literal></entry>
|
|
<entry>O mesmo que "%Y-%m-%d" (geralmente utilizado em carimbos de data em bancos de dados)</entry>
|
|
<entry>Exemplo: <literal>2009-02-05</literal> de February 5, 2009</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%s</literal></entry>
|
|
<entry>Timestamp Unix(o mesmo que a função <function>time</function>
|
|
function)</entry>
|
|
<entry>Exemplo: <literal>305815200</literal> de September 10, 1979 08:40:00 AM</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%x</literal></entry>
|
|
<entry>Representação da data baseada na preferência da localidade, sem a hora</entry>
|
|
<entry>Exemplo: <literal>02/05/09</literal> de February 5, 2009</entry>
|
|
</row>
|
|
<row>
|
|
<entry align="center"><emphasis>Miscelânea</emphasis></entry>
|
|
<entry>---</entry>
|
|
<entry>---</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%n</literal></entry>
|
|
<entry>Uma nova linha ("\n")</entry>
|
|
<entry>---</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%t</literal></entry>
|
|
<entry>Um caractere TAB ("\t")</entry>
|
|
<entry>---</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>%%</literal></entry>
|
|
<entry>Um caractere literal de porcento ("%")</entry>
|
|
<entry>---</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</para>
|
|
<warning>
|
|
<simpara>
|
|
Contrário a ISO-9899:1999, o sistema Sun Solaris começa a semana no Domingo, como 1. Resultando
|
|
em <literal>%u</literal> não funcionando como descrito neste
|
|
manual.
|
|
</simpara>
|
|
</warning>
|
|
<warning>
|
|
<para>
|
|
<emphasis>Somente no Windows:</emphasis>
|
|
</para>
|
|
<para>
|
|
O modificador <literal>%e</literal> não possui suporte a implementação
|
|
desta função no Windows. Para conseguir este valor, o
|
|
modificador <literal>%#d</literal> pode ser utilizado em substituição. O exemplo a seguir
|
|
ilustra como escrever uma função com compatibilidade multiplataforma.
|
|
</para>
|
|
<para>
|
|
Os modificadores <literal>%z</literal> e <literal>%Z</literal>
|
|
retornam o nome do fuso horário em vez do deslocamento ou abreviação do mesmo.
|
|
</para>
|
|
</warning>
|
|
<warning>
|
|
<simpara>
|
|
<emphasis>macOS e musl somente:</emphasis> O modificador <literal>%P</literal>
|
|
não é suportado na implementação macOS desta função.
|
|
</simpara>
|
|
</warning>
|
|
</listitem>
|
|
</varlistentry>
|
|
|
|
&date.timestamp.description;
|
|
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Retorna uma string formatada de acordo com o <parameter>format</parameter>
|
|
informado em <parameter>timestamp</parameter> ou o horário local
|
|
atual se nenhum timestamp foi informado. Nomes de meses e dia da semana, e outras strings dependentes de linguagens
|
|
respeitam o idioma definido
|
|
com a função <function>setlocale</function>.
|
|
A função retorna &false; se <parameter>format</parameter> for vazio, contém especificadores
|
|
de conversão não suportados, ou se o comprimento da string retornada fosse
|
|
maior que <literal>4095</literal>.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="errors">
|
|
&reftitle.errors;
|
|
&date.timezone.errors.description;
|
|
<para>
|
|
Como a saída depende da biblioteca C disponível, alguns especificadores de
|
|
conversão não possuem suporte. No Windows, informar especificadores de
|
|
conversão desconhecidos resultará em mensagens <constant>E_WARNING</constant> e
|
|
retornará &false;. Em outros sistemas operacionais, pode não haver nenhuma
|
|
mensagem <constant>E_WARNING</constant> e a saída poderá conter os
|
|
especificadores de conversão não convertidos.
|
|
</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>
|
|
<parameter>timestamp</parameter> agora pode ser nulo.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
Este exemplo funciona se os respectivos idiomas estiverem instalados
|
|
no sistema.
|
|
<example>
|
|
<title>Exemplo da função <function>strftime</function> com idiomas</title>
|
|
<programlisting role="php" annotations="non-interactive">
|
|
<![CDATA[
|
|
<?php
|
|
setlocale(LC_TIME, "C");
|
|
echo strftime("%A");
|
|
setlocale(LC_TIME, "fi_FI");
|
|
echo strftime(" em finlandês é %A,");
|
|
setlocale(LC_TIME, "fr_FR");
|
|
echo strftime(" em francês %A e");
|
|
setlocale(LC_TIME, "de_DE");
|
|
echo strftime(" em alemão %A.\n");
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Exemplo do número de semana ISO 8601:1988 </title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
/* Dezembro 2002 / Janeiro 2003
|
|
ISOWk M Tu W Thu F Sa Su
|
|
----- ----------------------------
|
|
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 */
|
|
|
|
// Mostra: 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";
|
|
|
|
// Mostra: 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";
|
|
|
|
// Mostra: 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";
|
|
|
|
// Mostra: 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";
|
|
|
|
|
|
|
|
/* Dezembro 2004 / Janeiro 2005
|
|
ISOWk M Tu W Thu F Sa Su
|
|
----- ----------------------------
|
|
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 */
|
|
|
|
// Mostra: 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";
|
|
|
|
// Mostra: 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";
|
|
|
|
// Mostra: 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";
|
|
|
|
// Mostra: 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>Exemplo do uso do modificador <literal>%e</literal> compatível com múltiplas plataformas</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
// Jan 1: resulta em: '%e%1%' (%%, e, %%, %e, %%)
|
|
$format = '%%e%%%e%%';
|
|
|
|
// Verifica se está no Windows e substitui o modificador %e
|
|
// adequadamente
|
|
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
|
|
$format = preg_replace('#(?<!%)((?:%%)*)%e#', '\1%#d', $format);
|
|
}
|
|
|
|
echo strftime($format);
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Mostra os formatos conhecidos e desconhecidos</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
// Descreve os formatos
|
|
$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 ("%")',
|
|
);
|
|
|
|
// Resultados
|
|
$strftimeValues = array();
|
|
|
|
// Avalia os formatos enqunto suprime os erros.
|
|
foreach ($strftimeFormats as $format => $description) {
|
|
if (false !== ($value = @strftime("%{$format}"))) {
|
|
$strftimeValues[$format] = $value;
|
|
}
|
|
}
|
|
|
|
// Encontra o valor mais longo
|
|
$maxValueLength = 2 + max(array_map('strlen', $strftimeValues));
|
|
|
|
// Reporta formatos conhecidos
|
|
foreach ($strftimeValues as $format => $value) {
|
|
echo "Formato conhecido : '{$format}' = ", str_pad("'{$value}'", $maxValueLength), " ( {$strftimeFormats[$format]} )\n";
|
|
}
|
|
|
|
// Reporta formatos desconhecidos
|
|
foreach (array_diff_key($strftimeFormats, $strftimeValues) as $format => $description) {
|
|
echo "Formato desconhecido : '{$format}' ", str_pad(' ', $maxValueLength), ($description ? " ( {$description} )" : ''), "\n";
|
|
}
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs.similar;
|
|
<screen>
|
|
<![CDATA[
|
|
Formato conhecido : 'A' = 'Friday' ( A full textual representation of the day )
|
|
Formato conhecido : 'B' = 'December' ( Full month name, based on the locale )
|
|
Formato conhecido : 'H' = '11' ( Two digit representation of the hour in 24-hour format )
|
|
Formato conhecido : 'I' = '11' ( Two digit representation of the hour in 12-hour format )
|
|
Formato conhecido : 'M' = '24' ( Two digit representation of the minute )
|
|
Formato conhecido : 'S' = '44' ( Two digit representation of the second )
|
|
Formato conhecido : 'U' = '48' ( Week number of the given year, starting with the first Sunday as the first week )
|
|
Formato conhecido : 'W' = '48' ( A numeric representation of the week of the year, starting with the first Monday as the first week )
|
|
Formato conhecido : 'X' = '11:24:44' ( Preferred time representation based on locale, without the date )
|
|
Formato conhecido : 'Y' = '2010' ( Four digit representation for the year )
|
|
Formato conhecido : 'Z' = 'GMT Standard Time' ( The time zone offset/abbreviation option NOT given by %z (depends on operating system) )
|
|
Formato conhecido : 'a' = 'Fri' ( An abbreviated textual representation of the day )
|
|
Formato conhecido : 'b' = 'Dec' ( Abbreviated month name, based on the locale )
|
|
Formato conhecido : 'c' = '12/03/10 11:24:44' ( Preferred date and time stamp based on local )
|
|
Formato conhecido : 'd' = '03' ( Two-digit day of the month (with leading zeros) )
|
|
Formato conhecido : 'j' = '337' ( Day of the year, 3 digits with leading zeros )
|
|
Formato conhecido : 'm' = '12' ( Two digit representation of the month )
|
|
Formato conhecido : 'p' = 'AM' ( UPPER-CASE "AM" or "PM" based on the given time )
|
|
Formato conhecido : 'w' = '5' ( Numeric representation of the day of the week )
|
|
Formato conhecido : 'x' = '12/03/10' ( Preferred date representation based on locale, without the time )
|
|
Formato conhecido : 'y' = '10' ( Two digit representation of the year )
|
|
Formato conhecido : 'z' = 'GMT Standard Time' ( Either the time zone offset from UTC or the abbreviation (depends on operating system) )
|
|
Formato conhecido : '%' = '%' ( A literal percentage character ("%") )
|
|
Formato desconhecido : 'C' ( Two digit representation of the century (year divided by 100, truncated to an integer) )
|
|
Formato desconhecido : 'D' ( Same as "%m/%d/%y" )
|
|
Formato desconhecido : 'E'
|
|
Formato desconhecido : 'F' ( Same as "%Y-%m-%d" )
|
|
Formato desconhecido : 'G' ( The full four-digit version of %g )
|
|
Formato desconhecido : 'J'
|
|
Formato desconhecido : 'K'
|
|
Formato desconhecido : 'L'
|
|
Formato desconhecido : 'N'
|
|
Formato desconhecido : 'O'
|
|
Formato desconhecido : 'P' ( lower-case "am" or "pm" based on the given time )
|
|
Formato desconhecido : 'Q'
|
|
Formato desconhecido : 'R' ( Same as "%H:%M" )
|
|
Formato desconhecido : 'T' ( Same as "%H:%M:%S" )
|
|
Formato desconhecido : '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 )
|
|
Formato desconhecido : 'e' ( Day of the month, with a space preceding single digits )
|
|
Formato desconhecido : 'f'
|
|
Formato desconhecido : 'g' ( Two digit representation of the year going by ISO-8601:1988 standards (see %V) )
|
|
Formato desconhecido : 'h' ( Abbreviated month name, based on the locale (an alias of %b) )
|
|
Formato desconhecido : 'i'
|
|
Formato desconhecido : 'k' ( Hour in 24-hour format, with a space preceding single digits )
|
|
Formato desconhecido : 'l' ( Hour in 12-hour format, with a space preceding single digits )
|
|
Formato desconhecido : 'n' ( A newline character ("\n") )
|
|
Formato desconhecido : 'o'
|
|
Formato desconhecido : 'q'
|
|
Formato desconhecido : 'r' ( Same as "%I:%M:%S %p" )
|
|
Formato desconhecido : 's' ( Unix Epoch Time timestamp )
|
|
Formato desconhecido : 't' ( A Tab character ("\t") )
|
|
Formato desconhecido : 'u' ( ISO-8601 numeric representation of the day of the week )
|
|
Formato desconhecido : 'v'
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
<note>
|
|
<simpara>
|
|
%G e %V, que são baseadas nos números de semana da ISO 8601:1988,
|
|
podem dar resultados inesperados (embora corretos), se o sistema numérico
|
|
não for reconhecido perfeitamente. Veja exemplos da %V nesta página do manual.
|
|
</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;">Ferramenta online para criação de formatos compatíveis com o 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;">Especificação Open Group da <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
|
|
-->
|