[英]How can I compare current server time with SQL Database timestamp?
I wanted to compare current time with predefined timestamp range (start_time and end_time) from database. 我想将当前时间与数据库中预定义的时间戳范围(start_time和end_time)进行比较。 But the query returns nothing. 但是查询不返回任何内容。 Will be grateful for any kind of help. 将不胜感激任何形式的帮助。
public function setCurrentGw() //Isn't allowed to set externally
{
$this->table='gameweek';
$current_time = new time();
$query="SELECT `gw`,`start_time`,`end_time` FROM `$this->table` WHERE `start_time`<=$current_time AND $current_time<=`end_time`";
if($q=mysql_query($query))
{
$temp=mysql_fetch_assoc($q);
$this->current_gw=$temp['gw'];
echo $temp['start_time'];
echo 'Current#'.$this->current_gw.'<br/>';
}
else
{
echo 'Technical Failure! Try Again';
}
}
OP声明NOW()
有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.