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
date/time question
Moderator: General Moderators
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: date/time question
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.
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Re: date/time question
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. 