Counting how much time already passed

Hello. I’m creating a page where you can post an advertisements.
When you open a detail page there should be a table with some information like exact date when was this ad added AND (here starts my problem): want to add an information when (in minutes and hours) an ad was added also.

For example:

got in my database two columns:

First column called ‘date_added’ and a second called ‘time_added’.
First one has a variable

$written_date = date('d-m-Y');

and second:

$written_time = date('H:i');

and want to show this time like:

“15min ago”
“< 6 hours ago”
"< 3 days "
after 3 days it would just display a date and a time.

I know i can connect those variables using “.=”. But how should properly look a function to compute a time?

I can’t find anything useful and correct on google and php manual. The best option is to write a function with a variable to insert containing date and a time when this ad has been written. This function should return exact time.

I hope these informations below may be neccesary for some scripts/functions:

MySQL Server version: 5.1.48-log
MySQL client version: 4.1.22
phpMyAdmin Version information: 3.2.4

Thanks!

Have a look at the functions on this thread: http://www.sitepoint.com/forums/showthread.php?t=424140&highlight=web+date