Jayden_Blade Posted March 12, 2014 Share Posted March 12, 2014 I am trying to check if it has been one month or longer sense some one signed up for my site. I am doing something wrong. I want it to post the persons username if they have been on the site one month or less. db sign up date is in Y,m,d format. I know $datecheck is a number like 951170532. $b comes out to be something like 2014-3-11. <?php error_reporting(E_ALL); $year = (date('Y')); $month = (date('m')-1); $day = date(('d')); //echo "$month, $day, $year"; $datecheck = mktime($year,$month,$day,0,0,0); include ('database.php'); $new = mysql_query("SELECT DISTINCT username, signupdate FROM profiledata"); $a = mysql_fetch_array($new); $b = $a['signupdate']; if($b>=$datecheck){ print "<ul>"; while($users=mysql_fetch_array($b)){ print "<li>{$users[0]}</li>"; } } ?> Link to comment https://forums.phpfreaks.com/topic/286900-date-issues/ Share on other sites More sharing options...
Zane Posted March 12, 2014 Share Posted March 12, 2014 If you have the signup_date column set to a DATE type, then there's no reason to use PHP. SELECT id, signup_date FROM pdata WHERE signup_date >= DATE_SUB(NOW(), INTERVAL 30 DAY)That way, ONLY the users whose signup_date is a month old will be returned. Link to comment https://forums.phpfreaks.com/topic/286900-date-issues/#findComment-1472259 Share on other sites More sharing options...
Jayden_Blade Posted March 12, 2014 Author Share Posted March 12, 2014 Sweet. TY!! Link to comment https://forums.phpfreaks.com/topic/286900-date-issues/#findComment-1472260 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.