January 16, 2024 5:07 am

How to implement jquery Timeago with php

In social media we can see that posting time changes frequently seconds ago, minutes ago and hours ago etc, so today i am going to write a tutorial on timeago jquery and its easy implementation with PHP. Please follow the instruction given in download package to implement it in your web applications.

jquery-time-ago

[wpdm_file id=29]DEMO

Code

Contains javascript code. $(this).timeago() here this element is refers to timeago class selector of the anchor tag.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.livequery.js"></script>
<script type="text/javascript" src="js/jquery.timeago.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".timeago").livequery(function() // LiveQuery 
{
$(this).timeago(); // Calling Timeago Function 
});
});
</script>

 //HTML & PHP Code

<?php
$time=time(); // Current time-stamp eg: 1371612613
$mtime=date("c", $time); // Converts to date format 2013-06-19T03:30:13+00:00 
?>

You opened this page <a href='#' class='timeago' title="<?php echo $mtime; ?>"></a>

Author Huzoor Bux

I am Huzoor Bux from Karachi (Pakistan). I have been working as a PHP Developer from last 5+ years, and its my passion to learn new things and implement them as a practice. Basically I am a PHP developer but now days exploring more in HTML5, CSS and jQuery libraries.


Tutorial Categories:

One response to “How to implement jquery Timeago with php”

  1. roy says:

    it refused to work

Leave a Reply

Your email address will not be published. Required fields are marked *