Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Mar 2005
    Posts
    156
    Thanks
    8
    Thanked 1 Time in 1 Post

    Date in the past

    hello all,

    I'm currently storing $lastLogin as

    PHP Code:
    date('n/j/Y'); 
    and I need to see if last login was 6 months ago, which would be

    PHP Code:
    mktime(000date("n")-6date("j"),   date("Y")); 
    My question is, how do I break up the $lastLogin to see if $lastLogin was greater than 6 months ago. I'm guessing I can strstr it, but I think I will run into conflict with the years rolling over.

    Any comments appreciated.

    Thanks,
    ziggy

  • #2
    Senior Coder TheShaner's Avatar
    Join Date
    Sep 2005
    Location
    Orlando, FL
    Posts
    1,126
    Thanks
    2
    Thanked 40 Times in 40 Posts
    PHP Code:
    // $arrLogin[0] = n, $arrLogin[1] = j, $arrLogin[2] = Y in $lastLogin
    $arrLogin explode('/'$lastLogin);

    // Compare both timestamps to see if $loastLogin timestamp is greater than 6 months ago timestamp
    if (mktime(000$arrLogin[0], $arrLogin[1], $arrLogin[2]) > mktime(000date("n")-6date("j"), date("Y")))
      echo 
    "Last Login is greater than 6 months ago";
    else
      echo 
    "Last Login is less than or equal to 6 months ago"
    -Shane

  • #3
    Regular Coder
    Join Date
    Mar 2005
    Posts
    156
    Thanks
    8
    Thanked 1 Time in 1 Post
    my friend... you are the man... works like a charm... and caused me to learn a new functions.. explode();

    Thanks a ton,
    ziggy


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •