tags:

views:

20

answers:

1

Hi

I need to extract a list of all usernames from the user table in vBulletin of persons who were registered up to a certain date. So for example, I need all members up until 1st Oct, but after that is not required.

The 'joindate' field is expressed in seconds I think. Eg. 1116022743. How can I can extract usernames on this basis?

cheers

A: 

Hard to give you an exact answer without knowing the VB table structure, but the query would be something like

$date = strtotime('10/01/2010'); 
/* this is the date you are basing our query on
we make a timestamp of it for comparison */

$sql = "SELECT * FROM `vb_users_table` WHERE `joindate` <= '$date'";

those "seconds" are timestamps btw (technically seconds, but the correct term is timestamp).

example:

<?php

$date = strtotime('10/01/2010'); //1st oct 2010
$old = strtotime('3/9/2009'); // 9th mar 2009
$new = strtotime('3/9/2011') // 9th mar 2011

/* substitute $old with $new to see the effect */
if($old<=$date) { 
    echo date('d M Y', $old) . ' is before ' . date('d M Y', $date);
} else {
    echo date('d M Y', $old) . ' is not before ' . date('d M Y', $date);
}
Ross