date/time question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dbusher
Forum Newbie
Posts: 1
Joined: Tue Jun 10, 2008 8:33 pm

date/time question

Post by dbusher »

I am a newbie at php but having a good time learning to use it to access my database.
I have a table with a field filled by now() an example would be:
20080610133822

I wrote a php script that gets the last 5 rows from the database and displays it on the webpage. an example would be like this:

TravelBug Name: Sue
Location: Asura
Difficulty: Easy
When posted: 20080610133822

Does anyone have a code snippet that would take this field and compare it to current time and post something like this:

TravelBug Name: Sue
Location: Asura
Difficulty: Easy
When posted: less than a minute ago

OR

....
When posted: 1 hour 4 min ago

Thanks for your help
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: date/time question

Post by RobertGonzalez »

Have you looked at hotscripts yet? You generally are not going to find people giving you code here. We will help you code it, but that is generally the extent of our help.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: date/time question

Post by superdezign »

Well, I just finished my website and since this was something that I developed for my website, I decided that it'd be the first piece of content I'd put up. Just visit this tutorial for displaying relative time of dates to the current time. I tried my best to explain as much as necessary. ;)
Post Reply