0
我在数据库中有一个字段,用于以时间戳格式存储用户的出生日期,现在我想添加一个搜索过滤器,其中只显示出现在两个最小或最大限制之间的出生日期的用户。例如。 minimum=20 years
和maximum=60 years
。我怎样才能比较这两个参数的时间戳日期? 我尝试了与wordpress
wp_query
喜欢如下:如何比较特定时间戳20到60年的时间戳?
$current = time();
$age_min = strtotime(date('Y')-$_REQUEST['age_min']);
$age_max = strtotime(date('Y')-$_REQUEST['age_max']);
//echo $age_min.'==='.$age_max;
$age = array($age_min,$age_max);
$bars = explode(',',$_REQUEST['bars']);
$radius = $_REQUEST['radius'];
$args = array('orderby' => 'registered',
'meta_key' => 'active',
'meta_value' => '1',
'order' => 'ASC',
'count_total' => true,
'meta_query' => array(array('key' => 'date_of_birth',
'value' => $age,
'compare' => 'BETWEEN',
'type' => 'DECIMAL',),));
$user_query = new WP_User_Query(array($args,'exclude'=>array($user_id)));
使用的标记dbms。 (它们中的许多在执行日期/时间时不符合ANSI SQL标准。)列数据类型? – jarlh
数据库是什么? – mitkosoft
http://stackoverflow.com/questions/10483123/comparing-timestamp-dates-in-mysql-with-date-only-parameter –