Date preview like facebook time ago using PHP

What is time ago?

Time Ago functionality is used to display time in a different format, so that we can:

  1. Display the time format, which is easy to understand.
  2. Display the time format similar to different time zone.
  3. Show time interactively in messaging and feeds.

We can do it easily by a php function. In this function we will calculate time using particular country timezone. If you have previous date and time then in this function it count time difference between current date and time with previous date on simple php logic. We will convert the difference in time stamp and get number of seconds between these date and time. From seconds we can easily get minutes, hours, days, weeks, months and years.

Time ago function implementation:

Download Sample Project Code

Share:

Leave your Comment

© 2024 Tanvir's Blog | All Rights Reserved