MySQL 查询中基本 mktime() 的问题
我尝试使用基本查询来了解数据库查询中的时间戳。我有一个带有“时间”字段的数据库,它是时间戳。我有一个基本查询来返回“时间”大于键控值($t1)的记录。我已检查 mytime() 的格式是否正确(注释掉以说明)。我今天的日期有一个记录。当我更改 $t1 的值时,我期望它返回或不返回......但事实并非如此。我哪里出错了?
date_default_timezone_set('欧洲/伦敦');
$year = '2011';
$month = '10';
$day = '11';
$t1 = mktime(0,0,0, $month, $day, $year);
//echo date("d/m/y : H:i:s", $t1); // this works fine!
mysql_select_db(DATABASE_NAME, $connection);
$client = "demo/";
$result = mysql_query
(
"SELECT *
FROM " .SESSIONDB. "
WHERE client = '$client'
AND page = 'interaction.php'
AND time > '$t1'
"
);
Im trying a basic query to learn about timestamps in db queries. I have a db with a field 'time' which is a timestamp. I have a basic query to return records where "time" is greater than a keyed value ($t1). I have checked that mytime() is formatted correctly (commented off to illustrate). I have a single record set to todays date. I'm expecting it to return or not as I change the value of $t1 ... but it's not. where am I going wrong?
date_default_timezone_set('Europe/London');
$year = '2011';
$month = '10';
$day = '11';
$t1 = mktime(0,0,0, $month, $day, $year);
//echo date("d/m/y : H:i:s", $t1); // this works fine!
mysql_select_db(DATABASE_NAME, $connection);
$client = "demo/";
$result = mysql_query
(
"SELECT *
FROM " .SESSIONDB. "
WHERE client = '$client'
AND page = 'interaction.php'
AND time > '$t1'
"
);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将记录设置为
并将变量设置为
但您使用 > 比较两者(超过)... 2 不是 > 2、它是 == 或 >=
:)
You set the record to
and you set your variable to
But you compare the two using > (more than)... 2 is not > 2, it is == or >=
:)