View Full Version : Adding a (added $ days ago) script, need help
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, 12: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, 02: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.
cheers guys, makes sense now!!
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.