视频持续时间转换PHP

时间:2015-02-05 15:58:49

标签: php

我有一个函数是什么转换视频持续时间示例= 856.7是14:17

function duration( $duration )
{
    $duration_formated  = NULL;
    $duration           = round($duration);
    if ( $duration > 3600 ) {
        $hours              = floor($duration/3600);
        $duration_formated .= sprintf('%02d',$hours). ':';
        $duration           = round($duration-($hours*3600));
    }
    if ( $duration > 60 ) {
        $minutes            = floor($duration/60);
        $duration_formated .= sprintf('%02d', $minutes). ':';
        $duration           = round($duration-($minutes*60));
    } else {
        $duration_formated .= '00:';
    }

    return $duration_formated . sprintf('%02d', $duration);
}

但我如何转换14:17以显示视频时长856.7

0 个答案:

没有答案