如何在codeigniter中插入当前日期的日间隔?

I need to add the start date and end date in table. So startdate should be current date and the end date is after 30 days from current date. I have tried to do it in following way but it not insert the record in table.

 public function insert_details()
      $data = array(
        'tran_id' => $transaction_id,               
         'start_date' => CURDATE(),
         'end_date' => DATE_ADD(CURDATE() + INTERVAL 30 DAY)             
       );    
  $this->db->insert('user_payments', $data);
   return $this->db->insert_id();
 }

Because ,

DATE_ADD(CURDATE() + INTERVAL 30 DAY) are MySQL functions,

You are treating them like PHP functions.

Pass them as a string to MySQL.

Change To:

'end_date' => "DATE_ADD(CURDATE() + INTERVAL 30 DAY)"

you can use $this->db->set() method, if you want to MySql function in query

public function insert_details()
  $this->db->set('tran_id', $transaction_id);
  $this->db->set('start_date', 'CURDATE()', false);
  $this->db->set('end_date', 'DATE_ADD(CURDATE() + INTERVAL 30 DAY)', false);

  $this->db->insert('user_payments');
   return $this->db->insert_id();
 }

try this

date('Y-m-d', strtotime(date('Y-m-d'). " + 30 days"));