Perad Posted October 8, 2007 Share Posted October 8, 2007 $lastlogin = strtotime($row['last_login']); $now = strtotime(now); $difference = date("u", $now) - date("u", $lastlogin); I want to know if there is an hour difference between now and when the user last logged in. How do I do this as I am completely failing when I try to subtract the two with date functions. Quote Link to comment https://forums.phpfreaks.com/topic/72299-subtracting-time/ Share on other sites More sharing options...
JasonLewis Posted October 8, 2007 Share Posted October 8, 2007 the last_login row, is that a datetime field in the database? Quote Link to comment https://forums.phpfreaks.com/topic/72299-subtracting-time/#findComment-364551 Share on other sites More sharing options...
Perad Posted October 8, 2007 Author Share Posted October 8, 2007 yes e.g. 2007-10-08 12:10:47 Quote Link to comment https://forums.phpfreaks.com/topic/72299-subtracting-time/#findComment-364552 Share on other sites More sharing options...
JasonLewis Posted October 8, 2007 Share Posted October 8, 2007 this does work, although it isnt how i'd do it: $lastlogin = date("h", strtotime("2007-10-08 08:32:47")); $now = date("h"); $difference = $now - $lastlogin; echo $now."<br>".$lastlogin."<br><br>"; echo $difference; Quote Link to comment https://forums.phpfreaks.com/topic/72299-subtracting-time/#findComment-364556 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.