Creating TimeAgo function in PHP

Many times while displaying time on website we need to do something extra.

This function script can give you time in days/hour/minutes/seconds ago format.

You just need to pass the mysql time to this function. like this:

Note: sometimes you may get time error while using this function because of timezone.
In such case you might need to correct time difference by subtracting the difference from time-stamp. You jst need to modify the first line of function by $time = strtotime($timeStr) - 37800;. where 37800 is time difference in milliseconds.

Ganesh Bhosale

From a laptop to a full organization, Ganesh has traveled a tough road. A commando, armed with the latest tech & a huge warehouse of knowledge, he leads by example & is here for the long haul. His strong belief in giving back more has borne rich fruits, both for his employees & clients.

You may also like...

Leave a Reply

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