Calculating The Difference Between Two Times

I am trying to calculate the difference between two times (stored in database as time(7) so i can add it to a total time counter in a seperate model

I have this code

  if (isset($_POST['Jobs'])) {


            $model->attributes = $_POST['Jobs'];


            $model->status = 2; //set status to closed

            //date time difference 

            $diff = $model->job_start - $model->job_end;

            //need to get customer model and add 

            $customermodel = Customers::model()->findByPk($model->customer_ID);

            $customermodel->total_time = $customermodel->total_time + $diff;


            if ($model->save())

                $this->redirect(array('view', 'id' => $model->job_ID));


But it throws this error

CDbCommand failed to execute the SQL statement: SQLSTATE[22007]: [Microsoft][SQL Server Native Client 11.0][SQL Server]Conversion failed when converting date and/or time from character string…

I realise this is because its converted the time to a string but does anyone know the correct way to accomplish this

You’ll need to convert the string to a datetime. This site will probably help.

Yeah it seems that is what is wrong here , looked at the site you linked but I am still stuck , thing I need it to convert to just time not date/time

Change this row and you will get the number of days between the two dates. If you want to get the difference in hours you need to change the last part of the row below.