Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
最后一小时在php中搜索_Php - Fatal编程技术网

最后一小时在php中搜索

最后一小时在php中搜索,php,Php,当时间还剩2小时时,我试图禁用按钮,下面是我的代码,但它总是转到其他位置。我如何解决此问题 $last_hour = strtotime('-2 hour', $auction['Item_Expired']); if ($auction['Item_Expired'] >= $last_hour) { echo ' <button type="button" class="btn btn-primary" d

当时间还剩2小时时,我试图禁用按钮,下面是我的代码,但它总是转到其他位置。我如何解决此问题

$last_hour = strtotime('-2 hour', $auction['Item_Expired']); 

     if ($auction['Item_Expired']  >= $last_hour) {

                           echo '  <button type="button" class="btn btn-primary" disabled id="agreeButton" data-dismiss="modal">Agree</button>';
                        } else {
                              echo '  <button type="button" class="btn btn-primary" id="agreeButton" data-dismiss="modal">Agree</button>';
                        } ?>
$last_hour=strottime('-2小时,$auction['Item_Expired']);
如果($auction['Item\u Expired']>=$last\u hour){
呼应“同意”;
}否则{
呼应“同意”;
} ?>

您正在做的事情的逻辑有问题

您将
Item\u Expired
时间戳作为
strotime
的相对起点,然后与
Item\u Expired
进行比较


我认为你应该与
now()比较。

你所做的事情的逻辑有问题

您将
Item\u Expired
时间戳作为
strotime
的相对起点,然后与
Item\u Expired
进行比较

我认为你应该与
now()

$last_hour=date('Y-m-d H:I:s',strotime('-1小时',strotime('Item_Expired']))进行比较;
$date=日期('Y-m-d H:i:s');
如果($date>=$last\u hour){
呼应“同意”;
}否则{
呼应“同意”;
} 
$last_hour=日期('Y-m-d H:i:s',标准时间('-1小时),标准时间($auction['Item_Expired']));
$date=日期('Y-m-d H:i:s');
如果($date>=$last\u hour){
呼应“同意”;
}否则{
呼应“同意”;
} 
$last_hour = date('Y-m-d H:i:s', strtotime('-1 hours', strtotime($auction['Item_Expired'])));

      $date = date('Y-m-d H:i:s');

      if ($date >= $last_hour) {

          echo '  <button type="button" class="btn btn-primary" disabled data-dismiss="modal">Agree</button>';
      }else{

          echo '  <button type="button" id ="agreeBtn" class="btn btn-primary">Agree</button>';
      }