Welcome Guest, Not a member yet? Register   Sign In
How to work with timestampdiff?
#1

Hi Friends,

Good Day!

I would like to ask some help in working with timestampdiff.

I wanted to get the time duration between the datastarted and dateresolved.
and the result will be automatically inserted into the database.

Below is my Report_Model Codes.
Code:
   function get_TimeDifference($id)
   {
     $this->db->where('id',$id);
     $this->db->select('TIMESTAMPDIFF(HOUR,DateStarted,DateRestored) as OutageDuration',FALSE);
     $query = $this->db->get('network_outage');
     return $query;
   }
Below also is my code in Controller

Code:
       function update_downtime($id)
         {
           $data['title'] = 'Update Network Downtime';
           $user_id = $this->uri->segment(3);
       


           $data['fetch_single_outage'] = $this->network_model->fetch_single_outage($user_id);
           $data['fecth_downtime'] = $this->network_model->get_outagelist();
           $data['get_ISPStatus'] = $this->network_model->get_ISPStatus();
           $this->load->view('template/header');
           $this->load->view('template/nav');
           $this->load->view('network/update_downtime',$data);
           $this->load->view('template/footer');
         }

         function network_update_form_validation()
         {
           $Outage = $this->report_model->get_TimeDifference($OutageDuration);
             $data  = array(
               'DateRestored' => $this->input->post('date_restored'),
               'Status' => $this->input->post('select_ticket_status'),
               'OutageDuration' => $Outage,
               'PerformedBy' => $this->session->userdata('user_name')
             );

             if($this->input->post('update'))
             {
                 $this->network_model->update_outage($data,$this->input->post('hidden_id'));

                 $this->session->set_flashdata('downtime_updated','Outage has been updated successfully');
                 redirect('network/network_outage');
             }
         }

Please see highlighted codes

Thank you and best regards,
Jay
Reply


Messages In This Thread
How to work with timestampdiff? - by rjay - 05-15-2019, 11:17 AM
RE: How to work with timestampdiff? - by php_rocs - 05-15-2019, 01:34 PM
RE: How to work with timestampdiff? - by rjay - 05-15-2019, 02:14 PM
RE: How to work with timestampdiff? - by php_rocs - 05-15-2019, 06:04 PM
RE: How to work with timestampdiff? - by InsiteFX - 05-16-2019, 02:32 PM
RE: How to work with timestampdiff? - by rjay - 05-20-2019, 08:53 AM



Theme © iAndrew 2016 - Forum software by © MyBB