Actually I working on a php website where User ads some entries in to database. At the time of insertion he adds one date field which also stored into db. Now I want the the age (how much time elapsed after saving that entry into database) of that entry. For that I calling one function to which I am passing that date & then using strtotime() function I am getting that time in seconds. For getting the elapsed time I am subtracting that converted time from current time. And here I am getting the main problem. It gives me NEGATIVE value. And I am stuck here so long & I am unable to figure it out why its returning negative value. Please help me out in this. Here is my tried code.
function timeSpan($string)
{
$timestamp = strtotime($string);
$now = time();
$timeSpan = $now-$timestamp;
...........
...........
}
Here I am passing the datetime as $string to the function which is saved in the db at the time of form submitting. I have saved the date with type "datetime". And now the $timeSpan variable is returning a negative value. Anybody have any idea why its returning negative value?