Jump to content

trouble with dates


treez

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?
Link to comment
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.