function embonus_convert_to_seconds in Embedded Media Field 6.2
Convert time from field into seconds.
Parameters
$time: Raw timemarker input from field.
1 call to embonus_convert_to_seconds()
- embonus_emfield_field_extra in contrib/
embonus/ embonus.module - Implementation of hook_emfield_field_extra().
File
- contrib/
embonus/ embonus.module, line 114
Code
function embonus_convert_to_seconds($time) {
$time_in_seconds = 0;
$time_split = split(':', $time);
$count = count($time_split);
// If it is already in seconds then don't do anything.
if ($count == 1) {
return intval($time);
}
foreach ($time_split as $unit) {
$count--;
// If hours or minutes multiply by appropriate amount.
if ($count > 0) {
// If it is hours multiply by 36000 if minutes multiply by 60.
$time_in_seconds += $unit * pow(60, $count);
}
else {
// If we are on the seconds unit then we do not need to do anything.
$time_in_seconds += $unit;
}
}
return $time_in_seconds;
}