<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: timestamp code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Mon, 06 Oct 2008 12:00:46 GMT</pubDate>
    <description>DZone Snippets: timestamp code</description>
    <item>
      <title>PHP : Hace Script / Ago Script</title>
      <link>http://snippets.dzone.com/posts/show/4674</link>
      <description>Hace Script / Ago Script&lt;br /&gt;if we call with a timestamp of a month ago, he print "Hace 1 mes". If you want this in english should traduction. Sorry my english&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;function hace($timestamp)&lt;br /&gt;{&lt;br /&gt;$diferencia = time() - $timestamp;&lt;br /&gt;	if($diferencia &gt; 0)&lt;br /&gt;	{&lt;br /&gt;$periodo = array("segundo", "minuto", "hora", "dia", "semana", "mes" , "a&amp;ntilde;o", "decada");&lt;br /&gt;$longitud = array(           "60"    , "60"  , "24" , "7"     , "4.35", "12"       , "10"    );&lt;br /&gt;	&lt;br /&gt;	for($j = 0; $diferencia &gt;= $longitud[$j]; $j++)&lt;br /&gt;	$diferencia /= $longitud[$j];&lt;br /&gt;	&lt;br /&gt;	$diferencia = round($diferencia);&lt;br /&gt;	&lt;br /&gt;	if($diferencia != 1)&lt;br /&gt;	{&lt;br /&gt;		if($periodo[$j] == "mes")&lt;br /&gt;		$periodo[$j].= "es";&lt;br /&gt;		else&lt;br /&gt;		$periodo[$j].= "s";&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	return "Hace &lt;b&gt;".$diferencia."&lt;/b&gt; ".$periodo[$j];&lt;br /&gt;	}&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 19 Oct 2007 08:34:22 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4674</guid>
      <author>Ricardo (Ricardo m. Garc&#237;a)</author>
    </item>
  </channel>
</rss>
