<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: PHP Date in Human Readable Form (Facebook Style)</title>
	<atom:link href="http://blog.evandavey.com/2008/04/php-date-in-human-readable-form-facebook-style.html/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.evandavey.com/2008/04/php-date-in-human-readable-form-facebook-style.html</link>
	<description>Tech tips, hints, and general musings. PHP, Perl, Mysql, Javascript, AJAX, JSON, Linux, Mac OSX</description>
	<lastBuildDate>Tue, 22 Nov 2011 00:50:30 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
	<item>
		<title>By: timestamp - SitePoint Forums</title>
		<link>http://blog.evandavey.com/2008/04/php-date-in-human-readable-form-facebook-style.html/comment-page-1#comment-1890</link>
		<dc:creator>timestamp - SitePoint Forums</dc:creator>
		<pubDate>Tue, 12 Jul 2011 16:45:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.evandavey.com/?p=78#comment-1890</guid>
		<description>[...] asking a similar question:  PHP: &#039;Posted 10 Minutes Ago&#039; or &#039;Posted 8 Days Ago&#039;  Another technique: PHP Date in Human Readable Form (Facebook Style) - Tech Thought  Wordpress uses the human_time_diff() function: human_time_diff &#124; A HitchHackers guide through [...]</description>
		<content:encoded><![CDATA[<p>[...] asking a similar question:  PHP: &#039;Posted 10 Minutes Ago&#039; or &#039;Posted 8 Days Ago&#039;  Another technique: PHP Date in Human Readable Form (Facebook Style) &#8211; Tech Thought  WordPress uses the human_time_diff() function: human_time_diff | A HitchHackers guide through [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://blog.evandavey.com/2008/04/php-date-in-human-readable-form-facebook-style.html/comment-page-1#comment-1763</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Tue, 14 Sep 2010 03:29:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.evandavey.com/?p=78#comment-1763</guid>
		<description>I got errors when I first tried this. But if you add this to the top line of the function, it seemed to work.

$timestamp = strtotime($timestamp); // Timestamp is coming from MySQL and needs converted first!</description>
		<content:encoded><![CDATA[<p>I got errors when I first tried this. But if you add this to the top line of the function, it seemed to work.</p>
<p>$timestamp = strtotime($timestamp); // Timestamp is coming from MySQL and needs converted first!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://blog.evandavey.com/2008/04/php-date-in-human-readable-form-facebook-style.html/comment-page-1#comment-1755</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Fri, 10 Sep 2010 06:41:13 +0000</pubDate>
		<guid isPermaLink="false">http://blog.evandavey.com/?p=78#comment-1755</guid>
		<description>Well that was a failure.  can&#039;t seem to post the lt/gt signs correctly.  Might as well delete all my comments.</description>
		<content:encoded><![CDATA[<p>Well that was a failure.  can&#8217;t seem to post the lt/gt signs correctly.  Might as well delete all my comments.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://blog.evandavey.com/2008/04/php-date-in-human-readable-form-facebook-style.html/comment-page-1#comment-1754</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Fri, 10 Sep 2010 06:00:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.evandavey.com/?p=78#comment-1754</guid>
		<description>This is the objective-c way:

NSDate *itemDate = [NSDate dateWithTimeIntervalSince1970:unixTimestamp];
NSTimeInterval difference = [[NSDate date] timeIntervalSinceDate:itemDate];

NSArray *periods = [NSArray arrayWithObjects:@&quot;second&quot;, @&quot;minute&quot;, @&quot;hour&quot;, @&quot;day&quot;, @&quot;week&quot;, @&quot;month&quot;, @&quot;year&quot;, @&quot;decade&quot;, nil];
float lengths[] = {60.0f, 60.0f, 24.0f, 7.0f, 4.35f, 12.0f, 10.0f};

NSString *ending = @&quot;ago&quot;;
if (difference = lengths[j] &amp;&amp; j &lt; 7) {
	difference /= lengths[j];
	j++;
} difference = round(difference);

NSString *period = (NSString*)[periods objectAtIndex:j];	
return [NSString stringWithFormat:@&quot;%i %@%@ %@&quot;, (int)difference, period, (difference!=1?@&quot;s&quot;:@&quot;&quot;), ending];</description>
		<content:encoded><![CDATA[<p>This is the objective-c way:</p>
<p>NSDate *itemDate = [NSDate dateWithTimeIntervalSince1970:unixTimestamp];<br />
NSTimeInterval difference = [[NSDate date] timeIntervalSinceDate:itemDate];</p>
<p>NSArray *periods = [NSArray arrayWithObjects:@"second", @"minute", @"hour", @"day", @"week", @"month", @"year", @"decade", nil];<br />
float lengths[] = {60.0f, 60.0f, 24.0f, 7.0f, 4.35f, 12.0f, 10.0f};</p>
<p>NSString *ending = @&#8221;ago&#8221;;<br />
if (difference = lengths[j] &amp;&amp; j &lt; 7) {<br />
	difference /= lengths[j];<br />
	j++;<br />
} difference = round(difference);</p>
<p>NSString *period = (NSString*)[periods objectAtIndex:j];<br />
return [NSString stringWithFormat:@&quot;%i %@%@ %@&quot;, (int)difference, period, (difference!=1?@&quot;s&quot;:@&quot;&quot;), ending];</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://blog.evandavey.com/2008/04/php-date-in-human-readable-form-facebook-style.html/comment-page-1#comment-1753</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Fri, 10 Sep 2010 05:56:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.evandavey.com/?p=78#comment-1753</guid>
		<description>Here is the objective-C way:

NSDate *itemDate = [NSDate dateWithTimeIntervalSince1970:unixTimestamp];
NSTimeInterval difference = [[NSDate date] timeIntervalSinceDate:itemDate];
	
NSArray *periods = [NSArray arrayWithObjects:@&quot;second&quot;, @&quot;minute&quot;, @&quot;hour&quot;, @&quot;day&quot;, @&quot;week&quot;, @&quot;month&quot;, @&quot;year&quot;, @&quot;decade&quot;, nil];
float lengths[] = {60.0f, 60.0f, 24.0f, 7.0f, 4.35f, 12.0f, 10.0f};
	
NSString *ending = @&quot;ago&quot;;
if (difference = lengths[j] &amp;&amp; j &lt; 8) {
	difference /= lengths[j];
	j++;
} difference = round(difference);

NSString *period = (NSString*)[periods objectAtIndex:j];	
return [NSString stringWithFormat:@&quot;%i %@%@ %@&quot;, (int)difference, period, (difference!=1?@&quot;s&quot;:@&quot;&quot;), ending];</description>
		<content:encoded><![CDATA[<p>Here is the objective-C way:</p>
<p>NSDate *itemDate = [NSDate dateWithTimeIntervalSince1970:unixTimestamp];<br />
NSTimeInterval difference = [[NSDate date] timeIntervalSinceDate:itemDate];</p>
<p>NSArray *periods = [NSArray arrayWithObjects:@"second", @"minute", @"hour", @"day", @"week", @"month", @"year", @"decade", nil];<br />
float lengths[] = {60.0f, 60.0f, 24.0f, 7.0f, 4.35f, 12.0f, 10.0f};</p>
<p>NSString *ending = @&#8221;ago&#8221;;<br />
if (difference = lengths[j] &amp;&amp; j &lt; <img src='http://blog.evandavey.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> {<br />
	difference /= lengths[j];<br />
	j++;<br />
} difference = round(difference);</p>
<p>NSString *period = (NSString*)[periods objectAtIndex:j];<br />
return [NSString stringWithFormat:@&quot;%i %@%@ %@&quot;, (int)difference, period, (difference!=1?@&quot;s&quot;:@&quot;&quot;), ending];</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jalopezsuarez</title>
		<link>http://blog.evandavey.com/2008/04/php-date-in-human-readable-form-facebook-style.html/comment-page-1#comment-1649</link>
		<dc:creator>jalopezsuarez</dc:creator>
		<pubDate>Wed, 10 Mar 2010 20:08:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.evandavey.com/?p=78#comment-1649</guid>
		<description>This version is better, because the posted one has some problems with decades. This version is also translated to SPANISH HUMAN READABLE DATE, which is almost the same as ENGLISH VERSION. 

function relativeTime($timestamp){
    $difference = time() - $timestamp; 
    $periods = array(&quot;segundo&quot;, &quot;minuto&quot;, &quot;hora&quot;, &quot;d&#237;a&quot;, &quot;semana&quot;, &quot;mes&quot;, &quot;a&#241;o&quot;, &quot;d&#233;cada&quot;); 
    $lengths = array(&quot;60&quot;,&quot;60&quot;,&quot;24&quot;,&quot;7&quot;,&quot;4.35&quot;,&quot;12&quot;,&quot;10&quot;); 

    if ($difference &gt; 0) { // this was in the past 
        $starting = &quot;Hace&quot;; 
    } else { // this was in the future 
        $difference = -$difference; 
        $starting = &quot;Falta&quot;; 
    }        
    
	$j = 0;    
    while ($difference &gt;= $lengths[$j] &amp;&amp; $j &lt; count($lengths)) { 
    	$difference /= $lengths[$j];      	
    	$j++;
    }  
    
    $difference = round($difference); 
    if($difference != 1) $periods[$j].= ($periods[$j]!=&quot;mes&quot;)?&quot;s&quot;:&quot;es&quot;;
    $text = &quot;$starting $difference $periods[$j]&quot;; 
    return $text; 
}</description>
		<content:encoded><![CDATA[<p>This version is better, because the posted one has some problems with decades. This version is also translated to SPANISH HUMAN READABLE DATE, which is almost the same as ENGLISH VERSION. </p>
<p>function relativeTime($timestamp){<br />
    $difference = time() &#8211; $timestamp;<br />
    $periods = array(&#8220;segundo&#8221;, &#8220;minuto&#8221;, &#8220;hora&#8221;, &#8220;d&iacute;a&#8221;, &#8220;semana&#8221;, &#8220;mes&#8221;, &#8220;a&ntilde;o&#8221;, &#8220;d&eacute;cada&#8221;);<br />
    $lengths = array(&#8220;60&#8243;,&#8221;60&#8243;,&#8221;24&#8243;,&#8221;7&#8243;,&#8221;4.35&#8243;,&#8221;12&#8243;,&#8221;10&#8243;); </p>
<p>    if ($difference &gt; 0) { // this was in the past<br />
        $starting = &#8220;Hace&#8221;;<br />
    } else { // this was in the future<br />
        $difference = -$difference;<br />
        $starting = &#8220;Falta&#8221;;<br />
    }        </p>
<p>	$j = 0;<br />
    while ($difference &gt;= $lengths[$j] &amp;&amp; $j &lt; count($lengths)) {<br />
    	$difference /= $lengths[$j];<br />
    	$j++;<br />
    }  </p>
<p>    $difference = round($difference);<br />
    if($difference != 1) $periods[$j].= ($periods[$j]!=&quot;mes&quot;)?&quot;s&quot;:&quot;es&quot;;<br />
    $text = &quot;$starting $difference $periods[$j]&quot;;<br />
    return $text;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raju</title>
		<link>http://blog.evandavey.com/2008/04/php-date-in-human-readable-form-facebook-style.html/comment-page-1#comment-1274</link>
		<dc:creator>Raju</dc:creator>
		<pubDate>Sat, 22 Aug 2009 22:51:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.evandavey.com/?p=78#comment-1274</guid>
		<description>Hello,
Thanks for this. today I have used it. great thing indeed.</description>
		<content:encoded><![CDATA[<p>Hello,<br />
Thanks for this. today I have used it. great thing indeed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DanielK</title>
		<link>http://blog.evandavey.com/2008/04/php-date-in-human-readable-form-facebook-style.html/comment-page-1#comment-959</link>
		<dc:creator>DanielK</dc:creator>
		<pubDate>Tue, 26 May 2009 21:54:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.evandavey.com/?p=78#comment-959</guid>
		<description>Thanks for this post - nice one, gave me the needed inspiration for a function I was writing.</description>
		<content:encoded><![CDATA[<p>Thanks for this post &#8211; nice one, gave me the needed inspiration for a function I was writing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://blog.evandavey.com/2008/04/php-date-in-human-readable-form-facebook-style.html/comment-page-1#comment-624</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Thu, 04 Dec 2008 20:51:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.evandavey.com/?p=78#comment-624</guid>
		<description>Just what I was looking for. Thanks for saving me some work!</description>
		<content:encoded><![CDATA[<p>Just what I was looking for. Thanks for saving me some work!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

