Jump to content


This topic is now archived and is closed to further replies.


trouble with dates

Recommended Posts

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?

Share this post

Link to post
Share on other sites
[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]

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.