Jump to content

date issues


Jayden_Blade
Go to solution Solved by Zane,

Recommended Posts

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>";
            }
}
?>
Edited by Jayden_Blade
Link to comment
Share on other sites

  • Solution

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. Edited by Zane
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.