treez Posted February 27, 2006 Share Posted February 27, 2006 On my users table on my mysql db i have a field called "lastlogin". This is the date when the person last logged on my site and is in the format "hh:mm:ss - dd:mm:yyyy" eg"13:46:28 - 18/11/2005"I want to make something so I can see who hasnt logged in within (x) amount of days.I know know to explode it so I can get just the 18/11/2005 bit but how would I make it so I can list only those entrys that havent logged in within (x) days? Link to comment https://forums.phpfreaks.com/topic/3653-trouble-with-dates/ Share on other sites More sharing options...
hitman6003 Posted February 27, 2006 Share Posted February 27, 2006 [code]function datediff($start, $end) { //will only work with date in format of dd/mm/yyyy $s = explode("/",$start); $e = explode("/",$end); $st = mktime(NULL, NULL, NULL, $s[1], $s[0], $s[2]); $et = mktime(NULL, NULL, NULL, $e[1], $e[0], $e[2]); $daysofdifference = floor(($et - $st) / 86400); return $daysofdifference;}$diff = datediff('18/11/2005', date('d-m-Y));echo "days since last visit: $diff";[/code] Link to comment https://forums.phpfreaks.com/topic/3653-trouble-with-dates/#findComment-12666 Share on other sites More sharing options...
treez Posted February 27, 2006 Author Share Posted February 27, 2006 Thanks! Link to comment https://forums.phpfreaks.com/topic/3653-trouble-with-dates/#findComment-12667 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.