I have searched,i had too many trial/errors but no luck.So here it goes:
I want to find out how many second have been elapsed since a date from Mysql entry which was inserted with NOW() and the current date in the format date("Y.m.d H:i:s").Here is my php function(taken from a user posted @stackoverflow).
function multipost(){
global $dbh;
$ip= $_SERVER['REMOTE_ADDR'];
$sql = "select * from table where ip='$ipa' order by date_time desc limit 1";
foreach ($dbh->query($sql) as $row) {
$timeFirst=$row['date_time'];
$timeSecond=date("Y.m.d H:i:s");
$differenceInSeconds = $timeSecond-$timeFirst;
echo $differenceInSeconds;
}
I have also tried strtotime($row['date_time'];) but no luck.
Any help?
Thanks in advance.
Copy this function.
To get difference of DATE and NOW:
To get difference of DATE TIME and NOW:
Hope it helps.