
September 30th, 2012, 01:17 PM
|
|
Registered User
|
|
Join Date: Sep 2012
Posts: 6
Time spent in forums: 40 m 29 sec
Reputation Power: 0
|
|
|
i've done something similar before. You dump the date value into php and let your script calculate the difference. i don't guarantee the syntax is perfect since it's just off the top of my head from memory, but something along the lines of this should work :
*** somewhere up here you will have your mySQL recordset. "thePostDate" is assumed to be a standard date/time format***
<?php
$value1 = htmlentities($row_DatabaseRecord['thePostDate']; //gets the date from the database record
$today = time(); // standard function to get today's date
$days_since = ceil(abs($today - $value1) / 86400); // calculates the amount of days since the post, and rounds it to the nearest day
$outputString = "It has been ".$days_since." days since the post."; // creates the report string
echo $outputString;
?>
i highly doubt that's perfect code but all the elements are there. a couple of tweaks and it should work for you.
|