Almost, all social media websites change posting time frequently without refreshing the web page. You can see these phrases: seconds ago, one minute ago, two minutes ago and hours ago in the same post while time is passing and the page did not reload. Jquery developers developed timeago plugin to implement this feature in your site.

The best two plugins is:

1. Timeago plugin

2. Livestamp.js plugin

jQuery Timeago plugin :
It automatically updates fuzzy timestamps. It receives the time in an ISO 8601 timestamp.

How to implement Timeago plugin :

Step1 : include jquery.js and the timeago.js files in the head of your file

Step2 : Attach the timeago functionality in DOM ready to time elements that have a class named ‘ago’ or any name you choose.

After these javascript lines, every time element with ‘ago’ class and an ISO 8601 timestamp in the datetime attribute will be changed to view time ago phrases. So, this element :

Will be converted into:

Timeago Options :

Allow future :

You can allow timestamps in the future by changing the allowFuture setting to true.

jQuery.timeago.settings.allowFuture = true;

Disable past times :

You can disable past timestamps by changing the value of allowPast setting to false and add a phrase that appears when the timestamp in the past.

jQuery.timeago.settings.strings.inPast = “time over”;
jQuery.timeago.settings.allowPast = false;

jQuery Livestamp plugin:
It is a Jquery plugin that automatically updates time ago text depending on Moment.js. It can receive the time in UNIX timestamp and ISO 8601 timestamps.

How to implement Livestamp plugin :

Load jquery.js library, Moment.js, and livestamp.js in the head of your file

Once you loaded those files, the livestamp.js plugin will update any element with a data-livestamp attribute that has correct Unix timestamp into the desired format.

Will be updated to

Livestmp.js allows future time by default .

If you have any questions you can make a comment.Have a nice code.