mirror of
https://github.com/php/doc-pt_br.git
synced 2026-03-24 07:02:09 +01:00
253 lines
7.5 KiB
XML
253 lines
7.5 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- EN-Revision: 3a8c3e77df070a046c9d5b56b68926ca2d7e5ee3 Maintainer: leonardolara Status: ready --><!-- CREDITS: fabioluciano, leonardolara -->
|
|
<refentry xml:id="function.idate" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>idate</refname>
|
|
<refpurpose>Formata uma parte de uma data/horário local como um inteiro</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type class="union"><type>int</type><type>false</type></type><methodname>idate</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>
|
|
Retorna um número formatado de acordo com um formato informado utilizando o
|
|
inteiro <parameter>timestamp</parameter>, ou o horário local atual
|
|
se nenhum timestamp foi informado. Em outras palavras, <parameter>timestamp</parameter>
|
|
é opcional e tem como padrão o valor da função <function>time</function>.
|
|
</para>
|
|
<para>
|
|
Ao contrário da função <function>date</function>, a <function>idate</function>,
|
|
aceita apenas um caractere no parâmetro <parameter>format</parameter>.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>format</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
<table>
|
|
<title>Os caracteres a seguir são reconhecidos como válidos
|
|
no parâmetro <parameter>format</parameter></title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>Caractere <parameter>format</parameter></entry>
|
|
<entry>Descrição</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry><literal>B</literal></entry>
|
|
<entry>Swatch Beat/Horário da Internet</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>d</literal></entry>
|
|
<entry>Dia do mês</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>h</literal></entry>
|
|
<entry>Hora (no formato de 12 horas)</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>H</literal></entry>
|
|
<entry>Hora (no formato de 24 horas)</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>i</literal></entry>
|
|
<entry>Minutos</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>I</literal> (i maiúsculo)</entry>
|
|
<entry>retorna <literal>1</literal> se o horário de verão está ativo,
|
|
<literal>0</literal>, caso contrário</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>L</literal> (l maiúsculo)</entry>
|
|
<entry>retorna <literal>1</literal> para anos bissextos,
|
|
<literal>0</literal>, caso contrário</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>m</literal></entry>
|
|
<entry>Número do mês</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>N</literal></entry>
|
|
<entry>Dia da semana, baseado na ISO-8601 (<literal>1</literal> para segunda-feira
|
|
até<literal>7</literal> para domingo)</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>o</literal></entry>
|
|
<entry>ISO-8601 year (4 digits)</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>s</literal></entry>
|
|
<entry>Segundos</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>t</literal></entry>
|
|
<entry>Dias do mês atual</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>U</literal></entry>
|
|
<entry>Segundos desde a época Unix - January 1 1970 00:00:00 UTC -
|
|
isso é o mesmo que a função <function>time</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>w</literal></entry>
|
|
<entry>Dia da semana (<literal>0</literal> para domingo)</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>W</literal></entry>
|
|
<entry>Semana do ano, baseado na ISO-8601, com a semana começando na
|
|
segunda-feira</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>y</literal></entry>
|
|
<entry>Ano (1 ou 2 dígitos - veja a nota abaixo)</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>Y</literal></entry>
|
|
<entry>Ano (4 dígitos)</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>z</literal></entry>
|
|
<entry>Dia do ano</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>Z</literal></entry>
|
|
<entry>Deslocamento do fuso horário em segundos</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
|
|
&date.timestamp.description;
|
|
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Retorna um <type>int</type> em caso de sucesso, &return.falseforfailure;.
|
|
</para>
|
|
<para>
|
|
Como a função <function>idate</function> sempre retorna um <type>int</type> e
|
|
como ela não começa com um "0", <function>idate</function> pode retornar
|
|
menos dígitos do que se espera. Veja o exemplo abaixo.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="errors">
|
|
&reftitle.errors;
|
|
|
|
&date.timezone.errors.description;
|
|
|
|
</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.2.0</entry>
|
|
<entry>
|
|
Inclui os caracteres de formato <literal>N</literal> (dia da semana ISO-8601) e
|
|
<literal>o</literal> (ano ISO-8601).
|
|
</entry>
|
|
</row>
|
|
<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>
|
|
<example>
|
|
<title>Exemplo da função <function>idate</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$timestamp = strtotime('1st January 2004'); // 1072915200
|
|
|
|
// este código imprime o ano em um formato de dois dígitos
|
|
// entretanto, como começaria com um "0", ele
|
|
// só imprime "4"
|
|
echo idate('y', $timestamp) . "\n";
|
|
|
|
$timestamp = strtotime('1st January 2024'); // 1704067200
|
|
echo idate('y', $timestamp);
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
4
|
|
24
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><methodname>DateTimeInterface::format</methodname></member>
|
|
<member><function>date</function></member>
|
|
<member><function>getdate</function></member>
|
|
<member><function>time</function></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
|
|
-->
|