<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Blog do Beraldo &#187; time</title>
	<atom:link href="http://www.rberaldo.com.br/blog/tag/time/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rberaldo.com.br/blog</link>
	<description>Programação, Música, Entretenimento e o que mais me vier à mente</description>
	<lastBuildDate>Wed, 25 Jan 2012 14:23:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>TCP: Time To Live</title>
		<link>http://www.rberaldo.com.br/blog/tcp-time-to-live/</link>
		<comments>http://www.rberaldo.com.br/blog/tcp-time-to-live/#comments</comments>
		<pubDate>Mon, 07 Feb 2011 11:00:44 +0000</pubDate>
		<dc:creator>Beraldo</dc:creator>
				<category><![CDATA[Entretenimento]]></category>
		<category><![CDATA[Humor]]></category>
		<category><![CDATA[Imagens]]></category>
		<category><![CDATA[TCP/IP]]></category>
		<category><![CDATA[humor]]></category>
		<category><![CDATA[live]]></category>
		<category><![CDATA[tcp]]></category>
		<category><![CDATA[time]]></category>
		<category><![CDATA[tirinha]]></category>

		<guid isPermaLink="false">http://www.rberaldo.com.br/blog/?p=366</guid>
		<description><![CDATA[Tirinha satirizando o Time To Live, do protocolo TCP]]></description>
			<content:encoded><![CDATA[<p>Vou roubar um post do <a href="http://nerdson.com" onclick="urchinTracker('/outgoing/nerdson.com?referer=');">Nerdson</a>. :)</p>
<p><img src="http://nerdson.com/images/nerdson2/nerdson243.png" alt="TCP: Time To Live" /></p>
<p>fonte:<br />
<a href="http://nerdson.com/blog/mangled-packet/" onclick="urchinTracker('/outgoing/nerdson.com/blog/mangled-packet/?referer=');">http://nerdson.com/blog/mangled-packet</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rberaldo.com.br/blog/tcp-time-to-live/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP: Usando a classe nativa DateTime</title>
		<link>http://www.rberaldo.com.br/blog/php-usando-a-classe-nativa-datetime/</link>
		<comments>http://www.rberaldo.com.br/blog/php-usando-a-classe-nativa-datetime/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 18:36:49 +0000</pubDate>
		<dc:creator>Beraldo</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[Programação]]></category>
		<category><![CDATA[time]]></category>

		<guid isPermaLink="false">http://www.rberaldo.com.br/blog/?p=154</guid>
		<description><![CDATA[A partir do PHP 5.2.0, há uma maneira nativa e simples de se trabalhar com datas e horários, com ajuda da classe DateTime. Neste artigo, vou mostrar algumas das utilidades dessa classe.]]></description>
			<content:encoded><![CDATA[<p>A partir do PHP 5.2.0, há uma maneira nativa e simples de se trabalhar com datas e horários, com ajuda da classe <a href="http://br.php.net/manual/en/class.datetime.php" target="_blank" onclick="urchinTracker('/outgoing/br.php.net/manual/en/class.datetime.php?referer=');">DateTime</a>.</p>
<p>Neste artigo, vou mostrar algumas das utilidades dessa classe. Eu nunca a usei antes, estou aprendendo-a agora, enquanto monto o post. Logo, contribuições serão muito bem-vindas.</p>
<p>Vamos iniciar mostrando como funciona o construtor da classe.</p>
<p><span id="more-154"></span></p>
<p>Índice:<br />
<a href="#construct">1. Construtor da classe</a><br />
<a href="#format">2. Formatando datas</a><br />
<a href="#add">3. Adicionando períodos a datas</a><br />
<a href="#sub">4. Subtraindo períodos de uma data</a><br />
<a href="#diff">5. Calculando diferença entre datas</a><br />
<a href="#set">6. Modificando a data e a hora do objeto</a></p>
<h3><a name="construct">1. Construtor da classe</a></h3>
<p>Sintaxe do construtor:</p>
<p> <strong>DateTime::__construct  ([ string $time = "now"  [, DateTimeZone $timezone = NULL  ]] )</strong></p>
<p>Esse método aceita dois parâmetros, ambos opcionais. O primeiro é a data/hora, no mesmo formato aceito pela função <a href="http://br2.php.net/strftime" target="_blank" onclick="urchinTracker('/outgoing/br2.php.net/strftime?referer=');">strftime()</a>. O segundo consiste no <em>timezone</em> que deve ser utilizado. Ele deve ser uma instância da classe <a href="http://br2.php.net/manual/en/class.datetimezone.php" target="_blank" onclick="urchinTracker('/outgoing/br2.php.net/manual/en/class.datetimezone.php?referer=');">DateTimeZone</a>. Outra maneira de definir o <em>timezone</em> é por meio da função <a href="http://br.php.net/date_default_timezone_set" target="_blank" onclick="urchinTracker('/outgoing/br.php.net/date_default_timezone_set?referer=');">date_default_timezone_set()</a>.</p>
<p>Ambas as classes DateTime e DateTimeZone disparam uma exceção se seus construtores receberem parâmetro inválidos. Logo, podemos usar blocos try/catch para instanciar essas classes.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">try
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$DateTime</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DateTime<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'now'</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">new</span> DateTimeZone<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'America/Sao_Paulo'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
catch<span style="color: #009900;">&#40;</span> Exception <span style="color: #000088;">$e</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Erro ao instanciar objeto.&lt;br /&gt;'</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$e</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Experimente trocar o &#8220;now&#8221; por um valor não aceito pelo método, como uma string qualquer. Uma exceção será disparada.</p>
<h3><a name="format">2. Formatando datas</a></h3>
<p>Para formatar datas, usamos o método <em>format</em>, que aceita um parâmetro, correspondente a uma formatação de data aceita pela função <a href="http://br.php.net/manual/en/function.date.php" target="_blank" onclick="urchinTracker('/outgoing/br.php.net/manual/en/function.date.php?referer=');">date()</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$DateTime</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DateTime<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$DateTime</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">format</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;d/m/Y H:i:s&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$DateTime</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">format</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;Y-m-d H:i:s&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$DateTime</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">format</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;Y/m/d H:i:s&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span></pre></div></div>

<h3><a name="add">3. Adicionando períodos a datas</a></h3>
<p>Com o método <em>add()</em>, podemos adicionar períodos à data salva no objeto DateTime. É possível adicionar períodos de dias, períodos de tempo ou ambos, seguindo a formatação aceita pelo método, que recebe um único parâmetro, o qual é uma instância da classe <a href="http://br.php.net/manual/en/class.dateinterval.php" target="_blank" onclick="urchinTracker('/outgoing/br.php.net/manual/en/class.dateinterval.php?referer=');">DateInterval</a>, responsável por manipular os dados do período especificado. </p>
<p>Os períodos são especificados da seguinte maneira: períodos de dias são precedidos pela letra &#8220;P&#8221;, seguidas de inteiros e seus respectivos identificadores de tempo (&#8220;D&#8221; para dias, &#8220;M&#8221; para meses e &#8220;Y&#8221; para anos). Períodos de tempo são precedidos pela letra &#8220;T&#8221; e seguidos de inteiros e seus respectivos identificadores de unidade (&#8220;H&#8221; para horas, &#8220;M&#8221; para minutos e &#8220;S&#8221; para segundos).</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$DateTime</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DateTime<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$DateTime</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">add</span><span style="color: #009900;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> DateInterval<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;P30D&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// adiciona 30 dias</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$DateTime</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">format</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;d/m/Y&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$DateTime</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">add</span><span style="color: #009900;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> DateInterval<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;P2M&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// adiciona 2 meses</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$DateTime</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">format</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;d/m/Y&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$DateTime</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">add</span><span style="color: #009900;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> DateInterval<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;P5Y&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// adiciona 5 anos</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$DateTime</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">format</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;d/m/Y&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$DateTime</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">add</span><span style="color: #009900;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> DateInterval<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;P5Y2M30D&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// adiciona 30 dias, 2 meses e 5 anos</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$DateTime</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">format</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;d/m/Y&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span></pre></div></div>

<p>Note que cada adição é feita com base na adição anterior, uma vez que cada soma modifica a data armazenada no objeto.</p>
<h3><a name="sub">4. Subtraindo períodos de uma data</a></h3>
<p>O método <em>sub</em> funciona da mesma forma que o <em>add</em>, com a mesma lista de parâmetros, mas, logicamente, em vez de adicionar períodos, ele os subtrai.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$DateTime</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DateTime<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$DateTime</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sub</span><span style="color: #009900;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> DateInterval<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;P30D&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// subtrai 30 dias</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$DateTime</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">format</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;d/m/Y&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$DateTime</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sub</span><span style="color: #009900;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> DateInterval<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;P2M&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// subtrai 2 meses</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$DateTime</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">format</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;d/m/Y&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$DateTime</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sub</span><span style="color: #009900;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> DateInterval<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;P5Y&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// subtrai 5 anos</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$DateTime</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">format</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;d/m/Y&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$DateTime</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sub</span><span style="color: #009900;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> DateInterval<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;P5Y2M30D&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// subtrai 30 dias, 2 meses e 5 anos</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$DateTime</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">format</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;d/m/Y&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span></pre></div></div>

<h3><a name="diff">5. Calculando diferença entre datas</a></h3>
<p>Usando o método <em>diff</em>, podemos calcular o intervalo entre duas datas, com precisão de dias, meses, anos, horas, minutos e segundos. Esse método retorna uma instância da classe DateInterval, já citada anteriormente neste artigo.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$DateTime</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DateTime<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$diff</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$DateTime</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">diff</span><span style="color: #009900;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> DateTime<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'2009-02-14'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Diferença de:&lt;br /&gt;
&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$diff</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">d</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; dias&lt;br /&gt;
&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$diff</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">m</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; meses&lt;br /&gt;
&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$diff</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">y</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; anos&lt;br /&gt;
&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$diff</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">h</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; horas&lt;br /&gt;
&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$diff</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">i</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; minutos&lt;br /&gt;
&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$diff</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">s</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; segundos&lt;br /&gt;
&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<h3><a name="set">6. Modificando a data e a hora do objeto</a></h3>
<p>Para modificar a data e a hora armazenadas no objeto, utilizamos os métodos <em>setDate</em> e <em>setTime</em>.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$DateTime</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DateTime<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$DateTime</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">format</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;d/m/Y H:i&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$DateTime</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setDate</span><span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">2007</span><span style="color: #339933;">,</span> <span style="color: #208080;">07</span><span style="color: #339933;">,</span> <span style="color: #208080;">07</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$DateTime</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setTime</span><span style="color: #009900;">&#40;</span> <span style="color: #208080;">07</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">27</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$DateTime</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">format</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;d/m/Y H:i&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span></pre></div></div>

<p>Espero que tenha ficado tudo claro para todos. A utilização das classes não é difícil. Mais informações podem ser obtidas na documentação oficial.</p>
<p>Link úteis:<br />
<a href="http://br.php.net/manual/en/class.datetime.php" target="_blank" onclick="urchinTracker('/outgoing/br.php.net/manual/en/class.datetime.php?referer=');">Documentação da classe DateTime</a><br />
<a href="http://br.php.net/manual/en/class.datetimezone.php" target="_blank" onclick="urchinTracker('/outgoing/br.php.net/manual/en/class.datetimezone.php?referer=');">Documentação da classe DateTimeZone</a><br />
<a href="http://br.php.net/manual/en/class.dateinterval.php" target="_blank" onclick="urchinTracker('/outgoing/br.php.net/manual/en/class.dateinterval.php?referer=');">Documentação da classe DateTimeInterval</a><br />
<a href="http://br.php.net/manual/en/ref.datetime.php" target="_blank" onclick="urchinTracker('/outgoing/br.php.net/manual/en/ref.datetime.php?referer=');">Funções de data e hora do PHP</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rberaldo.com.br/blog/php-usando-a-classe-nativa-datetime/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

