Welcome! Log In Create A New Profile


Time ago instead of Date & Time in PHP

Posted by riaand-77568672 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
avatar Time ago instead of Date & Time in PHP
March 20, 2013 02:04PM
Hi everyone

I have previously read PHP Eleven - Date and Time Functions in PHP to look for the following issue I am having, but did not find anything.
The suggested the main site here, but still no luck.
I am currently running a site witch displays the tome like this: 2013-03-19 17:02:43
I would like to display it like this - one day one 1 minute ago, 6 minutes ago, 3 hours ago, 2 days ago, 3 weeks ago, 1 month ago, 2 months ago, etc. (similar to Twitter)

Here is my PHP code displayed in a table:

Language: PHP
echo "<td bgcolor=\"7D7978\" class=';table7';>" . $row[';time';] . "</td>";

and here is my MySQL entry:

Language: SQL
avatar Re: Time ago instead of Date & Time in PHP
March 20, 2013 03:47PM
you can format your time the way you want check www.php.net

gbakamela [77234715]
Re: Time ago instead of Date & Time in PHP
March 20, 2013 04:26PM
I am not on twitter, but from the top of my head, you will have the original datestamp in the db (when the post was first made), then get the date and time now (as the post is being read), then do some maths in the code (subtracting the posted date and time form the read date and time), and echo the result, formatting the code along the way.
Sorry, only registered users may post in this forum.

Click here to login