0

我正在尝试一个基本查询来了解数据库查询中的时间戳。我有一个带有“时间”字段的数据库,它是一个时间戳。我有一个基本查询来返回“时间”大于键值($t1)的记录。我检查了 mytime() 的格式是否正确(注释掉以说明)。我有一个记录设置为今天的日期。当我更改 $t1 的值时,我希望它会返回或不返回......但事实并非如此。我哪里错了?

  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'
        "
    ); 
4

1 回答 1

0

您将记录设置为

mktime(0,0,0, $month, $day, $year);

并且您将变量设置为

$t1 = mktime(0,0,0, $month, $day, $year);

但是您使用 >(大于)比较两者... 2 不是 > 2,而是 == 或 >=

:)

于 2011-10-11T18:28:39.737 回答