<p>Can anyone tell me how I can display a status message like "12 seconds ago" or "5 minutes ago" etc in a web page?</p>

[{'answer_id': 18693, 'author': 'Niyaz', 'author_id': 184, 'author_profile': 'https://Stackoverflow.com/users/184', 'pm_score': 7, 'selected': True, 'text': '<p>Here is the php code for the same:</p>\n\n<pre><code>function time_since($since) {\n    $chunks = array(\n        array(60 * 60 * 24 * 365 , \'year\'),\n        array(60 * 60 * 24 * 30 , \'month\'),\n        array(60 * 60 * 24 * 7, \'week\'),\n        array(60 * 60 * 24 , \'day\'),\n        array(60 * 60 , \'hour\'),\n        array(60 , \'minute\'),\n        array(1 , \'second\')\n    );\n\n    for ($i = 0, $j = count($chunks); $i &lt; $j; $i++) {\n        $seconds = $chunks[$i][0];\n        $name = $chunks[$i][1];\n        if (($count = floor($since / $seconds)) != 0) {\n            break;\n        }\n    }\n\n    $print = ($count == 1) ? \'1 \'.$name : "$count {$name}s";\n    return $print;\n}\n</code></pre>\n\n<p>The function takes the number of seconds as input and outputs text such as:</p>\n\n<ul>\n<li>10 seconds</li>\n<li>1 minute</li>\n</ul>\n\n<p>etc</p>\n'}, {'answer_id': 16248251, 'author': 'Dipesh', 'author_id': 1689396, 'author_profile': 'https://Stackoverflow.com/users/1689396', 'pm_score': 4, 'selected': False, 'text': '<pre><code>function timeAgo($timestamp){\n    $datetime1=new DateTime("now");\n    $datetime2=date_create($timestamp);\n    $diff=date_diff($datetime1, $datetime2);\n    $timemsg=\'\';\n    if($diff-&gt;y &gt; 0){\n        $timemsg = $diff-&gt;y .\' year\'. ($diff-&gt;y &gt; 1?"\'s":\'\');\n\n    }\n    else if($diff-&gt;m &gt; 0){\n     $timemsg = $diff-&gt;m . \' month\'. ($diff-&gt;m &gt; 1?"\'s":\'\');\n    }\n    else if($diff-&gt;d &gt; 0){\n     $timemsg = $diff-&gt;d .\' day\'. ($diff-&gt;d &gt; 1?"\'s":\'\');\n    }\n    else if($diff-&gt;h &gt; 0){\n     $timemsg = $diff-&gt;h .\' hour\'.($diff-&gt;h &gt; 1 ? "\'s":\'\');\n    }\n    else if($diff-&gt;i &gt; 0){\n     $timemsg = $diff-&gt;i .\' minute\'. ($diff-&gt;i &gt; 1?"\'s":\'\');\n    }\n    else if($diff-&gt;s &gt; 0){\n     $timemsg = $diff-&gt;s .\' second\'. ($diff-&gt;s &gt; 1?"\'s":\'\');\n    }\n\n$timemsg = $timemsg.\' ago\';\nreturn $timemsg;\n}\n</code></pre>\n'}, {'answer_id': 23475770, 'author': 'Sebastiaan Hilbers', 'author_id': 2450545, 'author_profile': 'https://Stackoverflow.com/users/2450545', 'pm_score': 3, 'selected': False, 'text': '<p>PHP\'s <code>\\DateTime::diff</code> returns a <a href="http://nl3.php.net/dateInterval" rel="noreferrer"><code>\\DateInterval</code></a> object on which you can get the minutes by the public <code>i</code> property.</p>\n'}]
['https://Stackoverflow.com/questions/18685', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/184/']