<?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: Twitter like N min/sec ago timestamp in PHP/MySQL</title> <atom:link href="http://viralpatel.net/blogs/2009/06/twitter-like-n-min-sec-ago-timestamp-in-php-mysql.html/feed" rel="self" type="application/rss+xml" /><link>http://viralpatel.net/blogs/2009/06/twitter-like-n-min-sec-ago-timestamp-in-php-mysql.html</link> <description>Tutorials, Java, J2EE, Struts, AJAX, JavaScript, CSS, Web 2.0, MySQL, Articles</description> <lastBuildDate>Wed, 08 Feb 2012 10:36:26 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>By: video youtube</title><link>http://viralpatel.net/blogs/2009/06/twitter-like-n-min-sec-ago-timestamp-in-php-mysql.html/comment-page-1#comment-18680</link> <dc:creator>video youtube</dc:creator> <pubDate>Thu, 15 Dec 2011 11:36:16 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=1337#comment-18680</guid> <description>Thanks a lot! very useful</description> <content:encoded><![CDATA[<p>Thanks a lot! very useful</p> ]]></content:encoded> </item> <item><title>By: Aaron Cruz</title><link>http://viralpatel.net/blogs/2009/06/twitter-like-n-min-sec-ago-timestamp-in-php-mysql.html/comment-page-1#comment-13111</link> <dc:creator>Aaron Cruz</dc:creator> <pubDate>Wed, 15 Sep 2010 15:09:16 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=1337#comment-13111</guid> <description>If you are using this for your own Twitter feed reader, just send a strtotime($created_at_string_from_twitter_timeline) into the function as the parameter. And thanks.  This is way prettier than my version.  I will definitely put a link to this post in my new stolen version!</description> <content:encoded><![CDATA[<p>If you are using this for your own Twitter feed reader, just send a strtotime($created_at_string_from_twitter_timeline) into the function as the parameter.<br /> And thanks.  This is way prettier than my version.  I will definitely put a link to this post in my new stolen version!</p> ]]></content:encoded> </item> <item><title>By: Carlos K</title><link>http://viralpatel.net/blogs/2009/06/twitter-like-n-min-sec-ago-timestamp-in-php-mysql.html/comment-page-1#comment-12629</link> <dc:creator>Carlos K</dc:creator> <pubDate>Thu, 03 Jun 2010 05:16:17 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=1337#comment-12629</guid> <description>Updated to fix some small errors: http://pastebin.com/e4chahvG</description> <content:encoded><![CDATA[<p>Updated to fix some small errors: <a href="http://pastebin.com/e4chahvG" rel="nofollow">http://pastebin.com/e4chahvG</a></p> ]]></content:encoded> </item> <item><title>By: Carlos K</title><link>http://viralpatel.net/blogs/2009/06/twitter-like-n-min-sec-ago-timestamp-in-php-mysql.html/comment-page-1#comment-12628</link> <dc:creator>Carlos K</dc:creator> <pubDate>Thu, 03 Jun 2010 05:04:38 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=1337#comment-12628</guid> <description>I&#039;ve ported this to JS, if anyone is interested. This would allow the page up be updated with the current &quot;time since&quot; in real time: http://pastebin.com/e4chahvG</description> <content:encoded><![CDATA[<p>I&#8217;ve ported this to JS, if anyone is interested. This would allow the page up be updated with the current &#8220;time since&#8221; in real time: <a href="http://pastebin.com/e4chahvG" rel="nofollow">http://pastebin.com/e4chahvG</a></p> ]]></content:encoded> </item> <item><title>By: Michael Fitzmaurice</title><link>http://viralpatel.net/blogs/2009/06/twitter-like-n-min-sec-ago-timestamp-in-php-mysql.html/comment-page-1#comment-12575</link> <dc:creator>Michael Fitzmaurice</dc:creator> <pubDate>Tue, 18 May 2010 21:06:53 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=1337#comment-12575</guid> <description>Used this and it worked straight out the box. Good work, thanks for sharing.</description> <content:encoded><![CDATA[<p>Used this and it worked straight out the box. Good work, thanks for sharing.</p> ]]></content:encoded> </item> <item><title>By: Viral Patel</title><link>http://viralpatel.net/blogs/2009/06/twitter-like-n-min-sec-ago-timestamp-in-php-mysql.html/comment-page-1#comment-11834</link> <dc:creator>Viral Patel</dc:creator> <pubDate>Fri, 25 Dec 2009 18:32:02 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=1337#comment-11834</guid> <description>@bsides - Thanks for the comment. Feel free to use the code from this site.</description> <content:encoded><![CDATA[<p>@bsides &#8211; Thanks for the comment. Feel free to use the code from this site.</p> ]]></content:encoded> </item> <item><title>By: bsides</title><link>http://viralpatel.net/blogs/2009/06/twitter-like-n-min-sec-ago-timestamp-in-php-mysql.html/comment-page-1#comment-11830</link> <dc:creator>bsides</dc:creator> <pubDate>Thu, 24 Dec 2009 13:31:05 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=1337#comment-11830</guid> <description>I used this today and works flawlessly. Thanks a lot :)</description> <content:encoded><![CDATA[<p>I used this today and works flawlessly. Thanks a lot <img src='http://viralpatel.net/blogs/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p> ]]></content:encoded> </item> <item><title>By: babu</title><link>http://viralpatel.net/blogs/2009/06/twitter-like-n-min-sec-ago-timestamp-in-php-mysql.html/comment-page-1#comment-11712</link> <dc:creator>babu</dc:creator> <pubDate>Sat, 28 Nov 2009 12:07:37 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=1337#comment-11712</guid> <description>ya its really nice</description> <content:encoded><![CDATA[<p>ya its really nice</p> ]]></content:encoded> </item> <item><title>By: John Grissom</title><link>http://viralpatel.net/blogs/2009/06/twitter-like-n-min-sec-ago-timestamp-in-php-mysql.html/comment-page-1#comment-10878</link> <dc:creator>John Grissom</dc:creator> <pubDate>Sat, 15 Aug 2009 21:51:42 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=1337#comment-10878</guid> <description>&lt;?phpfunction Timesince($original) { // array of time period chunks $chunks = array( array(60 * 60 * 24 * 365 , \&#039;year\&#039;), array(60 * 60 * 24 * 30 , \&#039;month\&#039;), array(60 * 60 * 24 * 7, \&#039;week\&#039;), array(60 * 60 * 24 , \&#039;day\&#039;), array(60 * 60 , \&#039;hour\&#039;), array(60 , \&#039;min\&#039;), array(1 , \&#039;sec\&#039;), );$today = time(); /* Current unix time  */ $since = $today - $original;// $j saves performing the count function each time around the loop for ($i = 0, $j = count($chunks); $i &lt; $j; $i++) {$seconds = $chunks[$i][0]; $name = $chunks[$i][1];// finding the biggest chunk (if the chunk fits, break) if (($count = floor($since / $seconds)) != 0) { break; } }$print = ($count == 1) ? \&#039;1 \&#039;.$name : \&quot;$count {$name}s\&quot;;if ($i + 1 &lt; $j) { // now getting the second item $seconds2 = $chunks[$i + 1][0]; $name2 = $chunks[$i + 1][1];// add second item if its greater than 0 if (($count2 = floor(($since - ($seconds * $count)) / $seconds2)) != 0) { $print .= ($count2 == 1) ? \&#039;, 1 \&#039;.$name2 : \&quot; $count2 {$name2}s\&quot;; } } return $print; } /* $body = str_replace(\&quot;:)\&quot;,\&quot;&lt;img src=\\\&quot;img/smilehappy.png\\\&quot;&gt;\&quot;,$body); $body = str_replace(\&quot;:(\&quot;,\&quot;&lt;img src=\\\&quot;img/smilesad.png\\\&quot;&gt;\&quot;,$body); $body = str_replace(\&quot;X(\&quot;,\&quot;&lt;img src=\\\&quot;img/smilemad.png\\\&quot;&gt;\&quot;,$body); $body = str_replace(\&quot;o.O\&quot;,\&quot;&lt;img src=\\\&quot;img/smileoO.png\\\&quot;&gt;\&quot;,$body); $body = str_replace(\&quot;&gt;&lt;\&quot;,\&quot;&lt;img src=\\\&quot;img/smilesquint.png\\\&quot;&gt;\&quot;,$body); $body = str_replace(\&quot;&gt;_&lt;\&quot;,\&quot;&lt;img src=\\\&quot;img/smileninja.png\\\&quot;&gt;\&quot;,$body); $body = str_replace(\&quot;:S\&quot;,\&quot;&lt;img src=\\\&quot;img/smilesick.png\\\&quot;&gt;\&quot;,$body); $body = str_replace(\&quot;zZz\&quot;,\&quot;&lt;img src=\\\&quot;img/smileZz.png\\\&quot;&gt;\&quot;,$body); $body = str_replace(\&quot;oO\&quot;,\&quot;&lt;img src=\\\&quot;img/smilepo.png\\\&quot;&gt;\&quot;,$body); */ $Psql=\&quot;SELECT F.`follower_id`, FU.username AS Name, U.`username` AS followerName FROM `following` F JOIN users U ON U.`id` = F.`user_id` JOIN users FU ON FU.`id` = F.`follower_id` WHERE F.`user_id` =\&quot;. $_SESSION[\&#039;userid\&#039;] .\&quot; LIMIT 0 , 3\&quot;;$Presult = mysql_query($Psql); while($Prows = mysql_fetch_array($Presult)){ $Ppsql=\&quot;SELECT `body`, UNIX_TIMESTAMP(stamp) FROM `posts` WHERE `user_id` = \&#039;\&quot;. $Prows[\&#039;follower_id\&#039;] .\&quot;\&#039; ORDER BY `stamp` DESC LIMIT 0,3\&quot;; $Ppresult=mysql_query($Ppsql); while($Pprows = mysql_fetch_array($Ppresult)){ echo \&quot;&lt;strong&gt;&lt;a href=\\\&quot;/\&quot;. $Prows[\&#039;Name\&#039;] .\&quot;\\\&quot;&gt;&lt;font color=black&gt;\&quot;.$Prows[\&#039;Name\&#039;] .\&quot;&lt;/font&gt;&lt;/a&gt;&lt;/strong&gt; &#124; \&quot;. $Pprows[\&#039;body\&#039;] .\&quot; &#124; \&quot;. $Pprows[\&#039;stamp\&#039;] .\&quot;&lt;hr&gt;&lt;br&gt;\&quot;; } }?&gt;</description> <content:encoded><![CDATA[<p>&lt;?php</p><p>function Timesince($original) {<br /> // array of time period chunks<br /> $chunks = array(<br /> array(60 * 60 * 24 * 365 , \&#8217;year\&#8217;),<br /> array(60 * 60 * 24 * 30 , \&#8217;month\&#8217;),<br /> array(60 * 60 * 24 * 7, \&#8217;week\&#8217;),<br /> array(60 * 60 * 24 , \&#8217;day\&#8217;),<br /> array(60 * 60 , \&#8217;hour\&#8217;),<br /> array(60 , \&#8217;min\&#8217;),<br /> array(1 , \&#8217;sec\&#8217;),<br /> );</p><p> $today = time(); /* Current unix time  */<br /> $since = $today &#8211; $original;</p><p> // $j saves performing the count function each time around the loop<br /> for ($i = 0, $j = count($chunks); $i &lt; $j; $i++) {</p><p> $seconds = $chunks[$i][0];<br /> $name = $chunks[$i][1];</p><p> // finding the biggest chunk (if the chunk fits, break)<br /> if (($count = floor($since / $seconds)) != 0) {<br /> break;<br /> }<br /> }</p><p> $print = ($count == 1) ? \&#8217;1 \&#8217;.$name : \&quot;$count {$name}s\&quot;;</p><p> if ($i + 1 &lt; $j) {<br /> // now getting the second item<br /> $seconds2 = $chunks[$i + 1][0];<br /> $name2 = $chunks[$i + 1][1];</p><p> // add second item if its greater than 0<br /> if (($count2 = floor(($since &#8211; ($seconds * $count)) / $seconds2)) != 0) {<br /> $print .= ($count2 == 1) ? \&#8217;, 1 \&#8217;.$name2 : \&quot; $count2 {$name2}s\&quot;;<br /> }<br /> }<br /> return $print;<br /> }<br /> /*<br /> $body = str_replace(\&quot;:)\&quot;,\&quot;&lt;img src=\\\&quot;img/smilehappy.png\\\&quot;&gt;\&quot;,$body);<br /> $body = str_replace(\&quot;:(\&quot;,\&quot;&lt;img src=\\\&quot;img/smilesad.png\\\&quot;&gt;\&quot;,$body);<br /> $body = str_replace(\&quot;X(\&quot;,\&quot;&lt;img src=\\\&quot;img/smilemad.png\\\&quot;&gt;\&quot;,$body);<br /> $body = str_replace(\&quot;o.O\&quot;,\&quot;&lt;img src=\\\&quot;img/smileoO.png\\\&quot;&gt;\&quot;,$body);<br /> $body = str_replace(\&quot;&gt;&lt;\&quot;,\&quot;&lt;img src=\\\&quot;img/smilesquint.png\\\&quot;&gt;\&quot;,$body);<br /> $body = str_replace(\&quot;&gt;_&lt;\&quot;,\&quot;&lt;img src=\\\&quot;img/smileninja.png\\\&quot;&gt;\&quot;,$body);<br /> $body = str_replace(\&quot;:S\&quot;,\&quot;&lt;img src=\\\&quot;img/smilesick.png\\\&quot;&gt;\&quot;,$body);<br /> $body = str_replace(\&quot;zZz\&quot;,\&quot;&lt;img src=\\\&quot;img/smileZz.png\\\&quot;&gt;\&quot;,$body);<br /> $body = str_replace(\&quot;oO\&quot;,\&quot;&lt;img src=\\\&quot;img/smilepo.png\\\&quot;&gt;\&quot;,$body);<br /> */</p><p>$Psql=\&quot;SELECT F.`follower_id`, FU.username AS Name, U.`username` AS followerName<br /> FROM `following` F<br /> JOIN users U ON U.`id` = F.`user_id`<br /> JOIN users FU ON FU.`id` = F.`follower_id`<br /> WHERE F.`user_id` =\&quot;. $_SESSION[\'userid\'] .\&quot;<br /> LIMIT 0 , 3\&quot;;</p><p>$Presult = mysql_query($Psql);<br /> while($Prows = mysql_fetch_array($Presult)){<br /> $Ppsql=\&quot;SELECT `body`, UNIX_TIMESTAMP(stamp) FROM `posts` WHERE `user_id` = \&#8217;\&quot;. $Prows[\'follower_id\'] .\&quot;\&#8217; ORDER BY `stamp` DESC LIMIT 0,3\&quot;;<br /> $Ppresult=mysql_query($Ppsql);<br /> while($Pprows = mysql_fetch_array($Ppresult)){<br /> echo \&quot;&lt;strong&gt;&lt;a href=\\\&quot;/\&quot;. $Prows[\'Name\'] .\&quot;\\\&quot;&gt;&lt;font color=black&gt;\&quot;.$Prows[\'Name\'] .\&quot;&lt;/font&gt;&lt;/a&gt;&lt;/strong&gt; | \&quot;. $Pprows[\'body\'] .\&quot; | \&quot;. $Pprows[\'stamp\'] .\&quot;&lt;hr&gt;&lt;br&gt;\&quot;;<br /> }<br /> }</p><p>?&gt;</p> ]]></content:encoded> </item> <item><title>By: John</title><link>http://viralpatel.net/blogs/2009/06/twitter-like-n-min-sec-ago-timestamp-in-php-mysql.html/comment-page-1#comment-9749</link> <dc:creator>John</dc:creator> <pubDate>Tue, 07 Jul 2009 23:54:17 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=1337#comment-9749</guid> <description>Hemm I cant seem to get this  to work I have a add_post function that add&#039;s the users post and as well as the time stamp. and I am trying to do this$sql = &quot;insert into posts (user_id, body, stamp) values ($userid, &#039;&quot; . mysql_real_escape_string($body) . &quot;&#039;, &#039;&quot;. $print .&quot;&#039;)&quot;;This ^^^^ is from another function</description> <content:encoded><![CDATA[<p>Hemm I cant seem to get this  to work I have a add_post function that add&#8217;s the users post and as well as the time stamp. and I am trying to do this</p><p>$sql = &#8220;insert into posts (user_id, body, stamp)<br /> values ($userid, &#8216;&#8221; . mysql_real_escape_string($body) . &#8220;&#8216;, &#8216;&#8221;. $print .&#8221;&#8216;)&#8221;;</p><p>This ^^^^ is from another function</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced

Served from: viralpatel.net @ 2012-02-09 10:21:23 -->
