<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >idate</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="Manual do PHP" HREF="index.html"><LINK REL="UP" TITLE="Data e hora" HREF="ref.datetime.html"><LINK REL="PREVIOUS" TITLE="gmstrftime" HREF="function.gmstrftime.html"><LINK REL="NEXT" TITLE="localtime" HREF="function.localtime.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Manual do PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.gmstrftime.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.localtime.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.idate" ></A >idate</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN26718" ></A ><P > (PHP 5)</P >idate -- Format a local time/date as integer</DIV ><DIV CLASS="refsect1" ><A NAME="AEN26721" ></A ><H2 >Descrição</H2 >int <B CLASS="methodname" >idate</B > ( string format [, int timestamp] )<BR ></BR ><P > Returns a number formatted according to the given format string using the given integer <CODE CLASS="parameter" >timestamp</CODE > or the current local time if no timestamp is given. In other words, <CODE CLASS="parameter" >timestamp</CODE > is optional and defaults to the value of <A HREF="function.time.html" ><B CLASS="function" >time()</B ></A >. </P ><P > Unlike the function <A HREF="function.date.html" ><B CLASS="function" >date()</B ></A >, <B CLASS="function" >idate()</B > accepts just one char in the <CODE CLASS="parameter" >format</CODE > parameter. </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN26740" ></A ><H2 >Parâmetros</H2 ><P > <P ></P ><DIV CLASS="variablelist" ><DL ><DT ><CODE CLASS="parameter" >format</CODE ></DT ><DD ><P > <DIV CLASS="table" ><A NAME="AEN26749" ></A ><P ><B >Tabela 1. The following characters are recognized in the <CODE CLASS="parameter" >format</CODE > parameter string</B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><COL><COL><THEAD ><TR ><TH ><CODE CLASS="parameter" >format</CODE > character</TH ><TH >Description</TH ></TR ></THEAD ><TBODY ><TR ><TD ><TT CLASS="literal" >B</TT ></TD ><TD >Swatch Beat/Internet Time</TD ></TR ><TR ><TD ><TT CLASS="literal" >d</TT ></TD ><TD >Day of the month</TD ></TR ><TR ><TD ><TT CLASS="literal" >h</TT ></TD ><TD >Hour (12 hour format)</TD ></TR ><TR ><TD ><TT CLASS="literal" >H</TT ></TD ><TD >Hour (24 hour format)</TD ></TR ><TR ><TD ><TT CLASS="literal" >i</TT ></TD ><TD >Minutes</TD ></TR ><TR ><TD ><TT CLASS="literal" >I</TT ></TD ><TD >returns <TT CLASS="literal" >1</TT > if DST is activated, <TT CLASS="literal" >0</TT > otherwise</TD ></TR ><TR ><TD ><TT CLASS="literal" >L</TT ></TD ><TD >returns <TT CLASS="literal" >1</TT > for leap year, <TT CLASS="literal" >0</TT > otherwise</TD ></TR ><TR ><TD ><TT CLASS="literal" >m</TT ></TD ><TD >Month number</TD ></TR ><TR ><TD ><TT CLASS="literal" >s</TT ></TD ><TD >Seconds</TD ></TR ><TR ><TD ><TT CLASS="literal" >t</TT ></TD ><TD >Days in current month</TD ></TR ><TR ><TD ><TT CLASS="literal" >U</TT ></TD ><TD >Seconds since the Unix Epoch - January 1 1970 00:00:00 GMT - this is the same as <A HREF="function.time.html" ><B CLASS="function" >time()</B ></A ></TD ></TR ><TR ><TD ><TT CLASS="literal" >w</TT ></TD ><TD >Day of the week (<TT CLASS="literal" >0</TT > on Sunday)</TD ></TR ><TR ><TD ><TT CLASS="literal" >W</TT ></TD ><TD >ISO-8601 week number of year, weeks starting on Monday</TD ></TR ><TR ><TD ><TT CLASS="literal" >y</TT ></TD ><TD >Year (1 or 2 digits - check note below)</TD ></TR ><TR ><TD ><TT CLASS="literal" >Y</TT ></TD ><TD >Year (4 digits)</TD ></TR ><TR ><TD ><TT CLASS="literal" >z</TT ></TD ><TD >Day of the year</TD ></TR ><TR ><TD ><TT CLASS="literal" >Z</TT ></TD ><TD >Timezone offset in seconds</TD ></TR ></TBODY ></TABLE ></DIV > </P ></DD ><DT ><CODE CLASS="parameter" >timestamp</CODE ></DT ><DD ><P > O parâmetro opcional <CODE CLASS="parameter" >timestamp</CODE > é um <A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A > Unix timestamp cujo padrão é a hora local se <CODE CLASS="parameter" >timestamp</CODE > não for dado. Em outras palavras, o padrão é o valor de <A HREF="function.time.html" ><B CLASS="function" >time()</B ></A >. </P ></DD ></DL ></DIV > </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN26842" ></A ><H2 >Valores de retornado</H2 ><P > Returns an <A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >. </P ><P > As <B CLASS="function" >idate()</B > always returns an <A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A > and as they can't start with a "0", <B CLASS="function" >idate()</B > may return fewer digits than you would expect. See the example below. </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN26850" ></A ><H2 >Erros/Excessões</H2 ><P > Toda a chamada a uma função de data/hora irá gerar um se a zona da hora não for valida, e/ou uma mensagem <TT CLASS="constant" ><B >E_STRICT</B ></TT > se estiver usando a definição do sistema ou a variável de ambiente <CODE CLASS="varname" >TZ</CODE >. Veja também <A HREF="function.date-default-timezone-set.html" ><B CLASS="function" >date_default_timezone_set()</B ></A ></P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN26856" ></A ><H2 >Histórico</H2 ><P > <DIV CLASS="informaltable" ><P ></P ><A NAME="AEN26859" ></A ><TABLE BORDER="1" CLASS="CALSTABLE" ><COL><COL><THEAD ><TR ><TH >Versão</TH ><TH >Descrição</TH ></TR ></THEAD ><TBODY ><TR ><TD >5.1.0</TD ><TD ><P > Agora emite <TT CLASS="constant" ><B >E_STRICT</B ></TT > e <TT CLASS="constant" ><B >E_NOTICE</B ></TT > em erros da zona de horario.</P ></TD ></TR ></TBODY ></TABLE ><P ></P ></DIV > </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN26872" ></A ><H2 >Exemplos</H2 ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN26875" ></A ><P ><B >Exemplo 1. <B CLASS="function" >idate()</B > example</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br />$timestamp </font><font color="#007700">= </font><font color="#0000BB">strtotime</font><font color="#007700">(</font><font color="#DD0000">'1st January 2004'</font><font color="#007700">); </font><font color="#FF8000">//1072915200<br /><br />// this prints the year in a two digit format<br />// however, as this would start with a "0", it<br />// only prints "4"<br /></font><font color="#007700">echo </font><font color="#0000BB">idate</font><font color="#007700">(</font><font color="#DD0000">'y'</font><font color="#007700">, </font><font color="#0000BB">$timestamp</font><font color="#007700">);<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN26879" ></A ><H2 >Veja também</H2 ><P > <P ></P ><TABLE BORDER="0" ><TBODY ><TR ><TD ><A HREF="function.date.html" ><B CLASS="function" >date()</B ></A ></TD ></TR ><TR ><TD ><A HREF="function.time.html" ><B CLASS="function" >time()</B ></A ></TD ></TR ></TBODY ></TABLE ><P ></P > </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.gmstrftime.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Principal</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.localtime.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >gmstrftime</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.datetime.html" ACCESSKEY="U" >Acima</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >localtime</TD ></TR ></TABLE ></DIV ></BODY ></HTML >