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. 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? 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 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; Link to comment https://forums.phpfreaks.com/topic/72299-subtracting-time/#findComment-364556 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.