Php 检查锁定日期

Php 检查锁定日期,php,Php,出于某种原因,检查当前_时间变量是否大于或小于登录时间的测试是不正确的。我不确定我错过了什么。$user\u数据对象的lock\u date属性表示用户上次登录失败的确切日期时间。 因此,它总是继续执行代码,并传递submit函数的其余部分 在比较这两次时,我考虑过在if语句中切换great than符号,但与这两次相比,我认为这没有意义 有人有其他想法吗 $current_time = now(); $current_gmt_human_format = unix_to_human($curr

出于某种原因,检查当前_时间变量是否大于或小于登录时间的测试是不正确的。我不确定我错过了什么。$user\u数据对象的lock\u date属性表示用户上次登录失败的确切日期时间。 因此,它总是继续执行代码,并传递submit函数的其余部分

在比较这两次时,我考虑过在if语句中切换great than符号,但与这两次相比,我认为这没有意义

有人有其他想法吗

$current_time = now();
$current_gmt_human_format = unix_to_human($current_time, TRUE, 'us');

/* Get user data from post username value */
$user_data = $this->users_model->get_by('username', $post_username);

if (count($user_data) > 0)
{
    /* User was found in database */

    if ($user_data->lock_date !== '0000-00-00 00:00:00')
    {
        /* User is locked out */

        /* How long the user must wait to login */
        $wait_time = 60 * 15;

        /* Time user is able to login */
        $time_to_login = strtotime($user_data->lock_date) + $wait_time; 

        //echo 'current time is...' . $current_time;
        //echo '<br>';
        //echo 'time to login is...' . $time_to_login;
        //die();

        if ($current_time < $time_to_login)
        {
        }
    }
}

看到一些真实的数据示例会很酷。这可能是DB和php时间和时区不匹配的问题。我发布了一些数据供您查看。now()函数有问题。它返回不应依赖于时区的unix时间戳。所以,如果我在本地机器上运行它,它应该会给我当前的时间。但这给了我未来的时间。使用codeigniter的now函数,你可以使用配置文件告诉它本地或gmt,我所有的时间都可以在gmt区域使用。我曾想过反转大于号,但那没有意义。似乎now()函数实际上返回本地时区中的时间(这是wierd,因为时间戳必须以GMT为单位)。尝试使用time()代替。有趣的是,如何在DB中设置lock_date以及列类型是什么?
current readable format is...2013-05-23 08:03:44 PM
current time is...1369353824
user lock out...1369310405
wait time is...900
time to login is...1369311305