毫秒转换为基本时间

问题描述:

我需要将1774132转换为30:42或30分42秒或任何输出。有没有这样的PHP函数?毫秒转换为基本时间

我发现这个网上一个很久以前,但我不知道在哪里了来自:

<?php 

function secondsToWords($seconds) 
{ 
    /*** return value ***/ 
    $ret = ""; 

    /*** get the hours ***/ 
    $hours = intval(intval($seconds)/3600); 
    if($hours > 0) 
    { 
     $ret .= "$hours hours "; 
    } 
    /*** get the minutes ***/ 
    $minutes = bcmod((intval($seconds)/60),60); 
    if($hours > 0 || $minutes > 0) 
    { 
     $ret .= "$minutes minutes "; 
    } 

    /*** get the seconds ***/ 
    $seconds = bcmod(intval($seconds),60); 
    $ret .= "$seconds seconds"; 

    return $ret; 
} 

echo secondsToWords(time()); 
?> 

像这样的东西应该工作:

printf("%d:%d:%d",$m/(1000*60*60), $m % (1000*60*60)/(1000*60),$m % (1000*60*60) % (1000*60)/1000);