0

我需要从 vBulletin 中的用户表中提取所有用户名的列表,这些用户名是在某个日期之前注册的人员。例如,在 10 月 1 日之前我需要所有成员,但在那之后就不需要了。

我认为“joindate”字段以秒为单位。例如。1116022743. 如何在此基础上提取用户名?

干杯

4

2 回答 2

0

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);
}
于 2010-10-14T08:38:19.357 回答
0

您可以使用UNIX_TIMESTAMPMySQL 函数来帮助构建查询。这是一个查询,它将提取 vBulletin 安装中所有用户的用户名,这些用户的加入日期在 2010 年 10 月 1 日之前:

SELECT username FROM user WHERE joindate < UNIX_TIMESTAMP('2010-10-01 00:00:00');

如果您想做相反的事情(将时间戳从 UNIX 格式转换为可读格式),您可以使用FROM_UNIXTIME.

于 2011-01-23T21:15:10.983 回答