How to convert timestamp to time ago in PHP?

In this post, I am going to describe the simple PHP function to create article post time ago function by using easy PHP codes. This utility function calculates the time differences in words. Many popular websites use this time format instead of showing the time like : 09 Nov 2014 12:20 PM they show like : 10 Minutes Ago.

Create a simple Function

Below is an example of Time Ago feature.

Example 1:

Use the bellow code snippets

Example 2:

Output

5 seconds ago

If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.

Recommended Posts:


Prem Tiwari

An engineer by profession and a passionate blogger by heart. Founder of FreeWebMentor.com (A Programming blog for beginners), Tech Speaker at various forums. A part from this he is an open source enthusiast, WordPress Lover, Blogger, SEO, and Growth Strategic.

Article Tags: