Timeago is nowadays used in social networking sites so, in this lesson today I'll Show you how to implement timeago to your site and it is very easy to implement into your site.
Here we are going to create a demo that will tell the visitor the time that he had spent on page.First include jQuery and timeago.js to your page then follow the code:
$(document).ready(function()
{
$(".timeago").timeago(); //Calling timeago function
});
HTML and PHP Code:
<?php
$time=time(); // Current timestamp eg: 1371612613
$mtime=date("c", $time); // Converts to date formate 2013-06-19T03:30:13+00:00
?>
<div class="container" >
You opened this page <abbr class='timeago' title="<?php echo $mtime; ?>" ></abbr>.
</div>
No comments:
Post a Comment