View Full Version : Adding a (added $ days ago) script, need help

01-17-2008, 11:21 AM

I am trying to write some php that outputs how long ago something was added to my database.

Just wondered what the easiest way of doing it is?

so it will output something like:
(added 2 days ago) or (added today) etc

Hope you can help

01-17-2008, 01:19 PM
Run the query such as:

"SELECT date FROM content WHERE id=$id"

And then fetch it to an array and wherever you want that date to be shown, add the echo for the row. You can change the date format to what you wish either in php, or I think during the query of the database

01-17-2008, 03:48 PM
I will expand a little on this one as well.
Depending on the format you save it, you will want to take the posted time in the database, and subtract it from the current time. The resulting time can be formatted to determine how many days ago it was posted with some rather simplistic calculations.

01-17-2008, 04:27 PM
cheers guys, makes sense now!!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum