date format time ago
<p>I'm still a beginner to PHP, but I need help with something. I got a date format for comments, and I'm trying to insert a "time ago" format. And I'm having trouble with it. This is the code:</p>

<pre><code>&lt;?php
$name = mysql_real_escape_string($_POST['name']);
$comment = mysql_real_escape_string($_POST['comment']);
$submit = $_POST['submit'];
$date = date("M jS Y | g:i a T");
$ip = "".$_SERVER['REMOTE_ADDR']."";

if($submit)
{
if($name&amp;&amp;$comment)
{

$query=mysql_query("

INSERT INTO comment (id, articleid, name, comment, date, ip) VALUES ('','".  mysql_real_escape_string($_GET['id']) ."','$name','$comment','$date','$ip')

");
header("Location: " . mysql_real_escape_string($_GET['id']) . "");

}
else
{
    echo "&lt;div class='red'&gt;You must fill in all fields!&lt;/div&gt;";
}
</code></pre>

<p>}
?></p>

<p>Here's the output:</p>

<pre><code>&lt;div class="article-body"&gt;
&lt;div class="user"&gt;&lt;b&gt;&lt;?php echo $row['name'] ?&gt;&lt;/b&gt; &lt;span&gt;says:&lt;/span&gt;&lt;/div&gt; 
&lt;div class="comments"&gt;
&lt;?php echo $row['comment'] ?&gt; &lt;br /&gt;&lt;p&gt;&lt;/p&gt;

&lt;p style="font-size:12px;"&gt;Posted on &lt;b&gt;&lt;?php echo $row['date'] ?&gt;&lt;/b&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>I tried fiddling with a couple codes by using Google, but none successful, as I'm a noob. Haha.</p>

<p>Any tuts on this? </p>

<p>Thanks!</p>
