我想显示过期的产品从数据库的日期最多有14天到期,下面的代码只显示1天到期的产品,请我想显示14天到期的产品以及
public function out_of_date(){
//$date=date('Y-n-j');
$date=date('Y-m-d');
$this->db->select('a.expeire_date as exp_date,a.*,b.*,c.*');
$this->db->from('product_purchase_details a');
$this->db->join('product_information c','c.product_id=a.product_id');
$this->db->join('view_m_total_batch_stock b','b.batch_id=a.batch_id');
$this->db->where('b.stock >',0);
$this->db->where('a.expeire_date <=', $date);
$this->db->group_by('b.batch_id');
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->result_array();
}
return false;
}
只需将$date
变量更改为14天前,如下所示
//$date=date('Y-m-d');
$date = (new DateTime())->sub(new DateInterval('P14D'))->format('Y-m-d');