I have checked this question (PHP/MySQL Display time since user's last login) and it didn't helped me.
I have a user table in MySQL database. Here are the fields of user table.
uid
name
password
last_login (type = timestamp)
Whenever user login to website last_login field get updated with current date time (yyyy-mm-dd hh:mm:ss).
I am able to update last_login field and it is working properly.
Now, I want to show difference between now and last_login time. I tried SQL query to get the detail but it is not working. Here is the SQL query.
mysql_query("SELECT DATEDIFF(NOW(), last_login) FROM user where uid=1");
I tried to check this query in phpMyAdmin but it returns 0.
Please advise what I am doing wrong.