I created a very simple custom formatter to convert an integer to hours minutes seconds using the format_interval() function.

$element = array();
foreach ($variables['#items'] as $delta => $item) {
  $element[$delta] = format_interval($item['value']);
}
return $element;

I'm not sure if this is the right way to go about it, but it worked, except I would get this notice on the output page. Notice: Array to string conversion in custom_formatters_field_formatter_view() (line 119 of \sites\all\modules\custom_formatters\includes\field.inc).

to get around this, in custom_formatters\includes\field.inc I changed.
$element[$delta]['#cf_options'] = isset($display['#cf_options']) ? $display['#cf_options'] : array();
to

if(is_array($element[$delta])){
  $element[$delta]['#cf_options'] = isset($display['#cf_options']) ? $display['#cf_options'] : array();
}

Comments

2pha’s picture

Status: Active » Closed (works as designed)

It seems like it was problem with how I was returning the data in the formatter.
The formatter code should have been this instead.

$element = array();
foreach ($variables['#items'] as $delta => $item) {
  $element[$delta] = array('#markup' => format_interval($item['value']));
}
return $element;