title: Item is not being deleted from database when time is expired
body: <p>I am trying to make deal of the day feature in online store. I can make any product deal of the day, so I will give expiry time and date so that product is automatically removed from deal of the day table in data base. My js code is</p>
  
  <pre><code>   $.ajax({
   url:'&lt;?php echo base_url() ?&gt;public_controller/get_deals_of_the_day',
   method:'post',
   dataType:'json',
   success:function(data) {
     console.log(data);
     let i;
     setInterval(function(){
       var today = new Date();
       var date = today.getDate()+'/'+(today.getMonth()+1)+'/'+today.getFullYear();
       var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
  
    for(i in data){
      var month = parseInt(data[i].expire_time.slice(0,2));
      var day = parseInt(data[i].expire_time.slice(3,5));
      var year = parseInt(data[i].expire_time.slice(6,10));
      var format = data[i].expire_time.slice(16,19);
      var hours = parseInt(data[i].expire_time.slice(11,13));
      if(format == 'PM' || format == ' PM'){
        hours = hours + 12;
      }
      // console.log(hours);
      var mins = parseInt(data[i].expire_time.slice(14,16));
      var cMonth = today.getMonth() + 1;
      var cDay = today.getDate();
      var cYear = today.getFullYear();
      var cHours = today.getHours();
      var cMins = today.getMinutes();
  
              if (cDay &gt;= day &amp;&amp; cHours &gt;= hours &amp;&amp; cMins &gt; mins) {
              let delId = data[i].product_id;
              console.log(delId);
              $.ajax({
                url:"&lt;?php echo base_url(); ?&gt;public_controller/del_deal",
                method:"post",
                data:{delId: delId},
                success:function(){
                  // alert('deal expired');
                  // location.reload(true);
                },
                error:function(e){
                  alert(e);
                }
              });
              }
     }
  
   }
    },1000);
  </code></pre>
  
  <p>});</p>
  
  <p>what i am doing is that I am fetching data of deal of the day table from database as the homepage loads and checking every second either any product has reached it's expiry time. When products any products expires it send id to controller to delete product from deal of the table. My controller method is</p>
  
  <pre><code>  public function del_deal(){
  $deal_id = $this-&gt;input-&gt;post('delId');
  $deal = $this-&gt;db-&gt;where('deal_id',$deal_id)-&gt;join('products','products.product_id = 
  deal_of_day.product_id')-&gt;get('deal_of_day')-&gt;row_array();
  $update['price'] = $deal['old_price'];
  $this-&gt;db-&gt;where('product_id',$deal['product_id'])-&gt;update('products',$update);
  $this-&gt;db-&gt;where('deal_id',$deal_id)-&gt;delete('deal_of_day');
  </code></pre>
  
  <p>}</p>
  
  <p>Condition is verifying I am just checking for day, hours and mins for testing purpose. Problem is it is not deleting product as conditions satisfies.
  I making online store in codeigniter framework. I haven't made any feature like this before so if I am doing or if there is better way to do it please suggest me that would be so helpful. </p>