Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/268.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 如何在codeigniter中将日期格式更改为strottime_Php_Codeigniter - Fatal编程技术网

Php 如何在codeigniter中将日期格式更改为strottime

Php 如何在codeigniter中将日期格式更改为strottime,php,codeigniter,Php,Codeigniter,我想在codeigniter中将日期格式转换为strotime,以交叉检查数据库中的过期日期 我的代码如下所示 $expiredate = date("Y-m-d H:i:s", strtotime(date("Y-m-d H:i:s",strtotime($tra->t_started)). '+30days')); if(strtotime(date("Y-m-d H:i:s"))

我想在codeigniter中将日期格式转换为strotime,以交叉检查数据库中的过期日期

我的代码如下所示

$expiredate = date("Y-m-d H:i:s", strtotime(date("Y-m-d H:i:s",strtotime($tra->t_started)). '+30days'));
                     
if(strtotime(date("Y-m-d H:i:s")) > strtotime($expiredate)){
    $ra->is_paid="1";
    //package is expired for 30days.
} else{
    $ra->is_paid="0";
    //package is expired for 30days.
}
                
我需要帮助来解决这个问题。谢谢这里的几个问题:

首先,您不需要使用
strotime
转换日期来比较它们

其次,要在日期上增加一定的天数,可以使用
+30天
(单数)而不是
+30天

你可以简单地:

$now = date('Y-m-d H:i:s');
$expire_date = date('Y-m-d H:i:s', strtotime($tra->t_started."+30 day"));

 if ($now >= $expire_date)
 {
      // 30 or more days overdue
 }

 else
 {
      // Less than 30 days overdue
 }

解决什么问题首先向我们展示foreach($result\u tra as$tra){$expiredate=date(“Y-m-dh:i:s”,strotime(date(“Y-m-dh:i:s”,strotime($tra->t\u start)).+30天”)中的内容;}@riggsfully,strotime对codeingeri没有作用,我不同意。我每天都在codeigniter上使用strotime,它工作得很好。也就是说,要增加30天,你应该使用
+30天
而不是
+30天
,不客气。如果这对您有效,那么获得您的upvote将是非常好的:)$tra->t_start=NULL,转到else条件。