Calculation Of Form Input Time Hh:mm Format Convert To Minutes


iam using multimodelform in which child records having one dropdown and 9 textfield for time duration of equipment life running hours(may be some 4000hours) in hh:mm format.

I want to explode each textfield with colon and multiply hours with 60minutes and add minutes figure to convert whole textfield input to minutes before saving in database.

where do i do all these calculations and how to do? please help as i tried searching web for solution and tired not getting any help.

plz help with example… as iam new to mvc but knows php.


you have to do this kind of operation in your model class

like this…

protected function afterFind ()


	if($this->pgm_approv_date != null && stripos($this->pgm_approv_date, '-')) {

        list($y, $m, $d) = explode('-', $this->pgm_approv_date);

        $mk=mktime(0, 0, 0, $m, $d, $y);

        $this->pgm_approv_date = date ('d.m.Y', $mk);


    return parent::afterFind ();


protected function beforesave ()


	if($this->pgm_approv_date != null && stripos($this->pgm_approv_date, '.')) {

        list($d, $m, $y) = explode('.', $this->pgm_approv_date);

        $mk=mktime(0, 0, 0, $m, $d, $y);

        $this->pgm_approv_date = date ('Y-m-d', $mk);


    return parent::beforesave ();


I hope this will help to solve ur problem

Thanks for your reply

This beforesave function works fine for main model.

 but not working in multimodelform.

i have two models, multimodelform uses second model for child records.

i used beforeSave function in second model class it displays white page with no error and no record adding in database.

plz help for any solution.


its my mistake your solution works fine and it solved my problem. thank you very much.

Thanks a lot i really struggled a lot for this problem for past couple of days.