How to Sum up 2 fields of integer, and present as "Time period"? I am building a drupal site.
I have 2 fields: "prep time"  and "cook time".
Both fields are: 
FIELD TYPE = Integer  
WIDGET = Time Period 

I need to sum up the two fields to one field (total time), and present it with widget of Time period, Or at least present it in time format ("2 hours 35 min").

Question Update (3/12/2013):
In addition, I need to present the date with ISO format in the HTML code (datetime="PT3H45M"). After I am using the Computed Field module, I don't know how to present the computed number as time format ("2 hours 35 min") and add the ISO format in the HTML code. as you will see below, I created a "field--field_preptime.tpl.php" that works great for the "prep time" and the "cook time", but when I am passing the computed value, the out put is wrong - as I don't see the the time format correctly, and the iso foramt in the html code is also wrong. 

can someone help me fix it?


here is how I created the prep time and cook time: 
I created the following field override template file called: "field--field_preptime.tpl.php"

&lt;?php
function time_to_iso8601_duration($time) { 
    $units = array(
        "Y" =&gt; 365*24*3600,
        "D" =&gt;     24*3600,
        "H" =&gt;        3600,
        "M" =&gt;          60,
        "S" =&gt;           1,
    );

    $str = "P";
    $istime = false;

    foreach ($units as $unitName =&gt; &amp;$unit) {
        $quot  = intval($time / $unit);
        $time -= $quot * $unit;
        $unit  = $quot;
        if ($unit &gt; 0) {
            if (!$istime &amp;&amp; in_array($unitName, array("H", "M", "S"))) { // There may be a better way to do this
                $str .= "T";
                $istime = true;
            }
            $str .= strval($unit) . $unitName;
        }
    }

    return $str;
}
 ?&gt;


&lt;div class="&lt;?php print $classes; ?&gt;"&lt;?php print $attributes; ?&gt;&gt;
  &lt;?php if (!$label_hidden): ?&gt;
    &lt;div class="field-label"&lt;?php print $title_attributes; ?&gt;&gt;&lt;?php print $label ?&gt;:&amp;nbsp;&lt;/div&gt;
  &lt;?php endif; ?&gt;
  &lt;div class="field-items"&lt;?php print $content_attributes; ?&gt;&gt;    
    &lt;?php foreach ($items as $delta =&gt; $item): ?&gt;
    &lt;?php $time = strtotime(render($item), 0); ?&gt;
      &lt;div class="field-item &lt;?php print $delta % 2 ? 'odd' : 'even'; ?&gt;"&lt;?php print $item_attributes[$delta]; ?&gt;&gt;&lt;/div&gt;
          &lt;time datetime=&lt;?php print time_to_iso8601_duration($time); ?&gt; itemprop="prepTime"&gt;&lt;?php print render($item); ?&gt;&lt;/time&gt;
    &lt;?php endforeach; ?&gt;
  &lt;/div&gt;
&lt;/div&gt;


The Output of "prep time", when I am viewing in the "view source" on the relevant page (I don't know how to do the same for the calculated value of "total time"):

&lt;div class="field field-name-field-preptime field-type-number-integer field-label-hidden"&gt;
    &lt;div id="md11" class="field-items"&gt;    
              &lt;div itemprop="prepTime" class="field-item even"&gt;&lt;/div&gt;
          &lt;time datetime="PT3H45M" itemprop="prepTime"&gt;3 hours 45 min&lt;/time&gt;
      &lt;/div&gt;
&lt;/div&gt;


Thanks.



UPDATE 1/10/2014: 
I couldn't do it without using computed fields. when I tried, I got an error: "Notice: Undefined variable: field_cooktime in include() (line 54 of D:\XXX\field--field_totaltime.tpl.php). I got the same error for preptime. 
I guess that is the reason the output is always 0 sec for total time, even though I put the totaltime field after the preptime and the cooktime fields. 

How can I get the value of two fields in my override template, and then Sum up?

Thanks.
One way to do this is the Computed Field module, which will allow you to use PHP to perform calculations.

To use this, you could add a field, Total time, of type Computed Field.  Then you could write some PHP code to calculate the value for Total time based on the other two fields.  This way, every time the node is updated, the correct calculation value will be saved in the Total Time field.

If you need to customize the display output, the Computed Field module allows you to optionally add PHP code to output the field for display with custom formatting as well.

But

Please note the warning on the module's page:


  This module is intended to be used by PHP developers to insert &amp;
  execute PHP code on a Drupal website. It does not provide a macro
  interface, a code builder or anything other than insert your working
  code here into this text area. You need to have a good working
  knowledge of PHP and the Drupal API to use this module. To get the
  best results with this module, pre-test your PHP code in the Body
  field of a Page in Drupal.