View Full Version : Date in the past

08-15-2007, 05:04 PM
hello all,

I'm currently storing $lastLogin as


and I need to see if last login was 6 months ago, which would be

mktime(0, 0, 0, date("n")-6, date("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.


08-15-2007, 05:25 PM
// $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(0, 0, 0, $arrLogin[0], $arrLogin[1], $arrLogin[2]) > mktime(0, 0, 0, date("n")-6, date("j"), date("Y")))
echo "Last Login is greater than 6 months ago";
echo "Last Login is less than or equal to 6 months ago";

08-15-2007, 06:35 PM
my friend... you are the man... works like a charm... and caused me to learn a new functions.. explode();

Thanks a ton,

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum