我的查询有问题,即使我现在发布帖子,TIMESTAMPDIFF也是如此 不适用于MINUTE。但是,如果我把DAY或MONTH付诸实施,我真的无法弄清楚可能是什么问题。我的帖子比秒更新。 如有任何帮助,将不胜感激
SELECT h2s_job.job_id,
h2s_job.job_title,
h2s_job.job_description,
h2s_job.job_category,
h2s_job.wantORoffering,
h2s_job.address,
h2s_job.cell,
h2s_job.email,
h2s_job.date_registered,
h2s_ad_info.date_registered,
h2s_job.user_id
FROM h2s_job
INNER JOIN h2s_ad_info ON h2s_job.user_id=h2s_ad_info.user_id
WHERE TIMESTAMPDIFF(MINUTE,h2s_ad_info.date_registered ,NOW())<1
答案 0 :(得分:1)
我假设date_registered
是TIMESTAMP
或DATETIME
。如果是这样,你可以这样做:
where NOW() - SECOND(h2s_ad_info.date_registered) < 1
答案 1 :(得分:1)
试试这个,
"SELECT TIMESTAMPDIFF(MINUTE, h2s_ad_info.date_registered, now()),
h2s_job.job_id,
h2s_job.job_title,
h2s_job.job_description,
h2s_job.job_category,
h2s_job.wantORoffering,
h2s_job.address,h2s_job.cell,
h2s_job.email,
h2s_job.date_registered,
h2s_job.user_id
From h2s_job
INNER JOIN h2s_ad_info
ON h2s_job.user_id=h2s_ad_info.user_id
where (TIMESTAMPDIFF(MINUTE, h2s_ad_info.date_registered, now()) < 1)";
这可能对你有所帮助。
答案 2 :(得分:0)
我发现了你的问题:它从你插入时间开始:转到你的数据库使date_registered数据类型为datetime:然后使用bellow函数并使用$ date_registered插入你的数据库:更改国家和城市得到正确的时间,因为这是你遇到问题的地方:我确定你的系统上的时间与你原来的不一样。所以针对你的国家和城市
<?php
# function to get right time
date_default_timezone_set('Africa/Johannesburg');
function time_diff_conv($start, $s)
{
$string="";
$t = array( //suffixes
'd' => 86400,
'h' => 3600,
'm' => 60,
);
$s = abs($s - $start);
foreach($t as $key => &$val) {
$$key = floor($s/$val);
$s -= ($$key*$val);
$string .= ($$key==0) ? '' : $$key . "$key ";
}
return $string . $s. 's';
}
date_registered = date('Y-m-d H:i:s');
# use this if u wanna show day friday like that date('l jS \of F Y \a\t h:i:s A')."\n";
# function to get right time
?>