开发者

Convert mm:ss to Milliseconds in PHP

Can you please let me know how to convert mm:ss to milliseconds 开发者_运维技巧in PHP.

$value = "10:10"

$ms = ...


No need to do string conversions or array manipulations:

sscanf($value, "%d:%d", $minutes, $seconds);
$ms = $seconds * 1000 + $minutes * 60 * 1000;


$ms = intval(substr($value, 0, 2))*60*1000 + intval(substr($value, 2, 2))*1000;


$value = "10:10";
$time = explode(':',$value);
$ms = $time[0]*60000 + $time[1]*1000;


$value = "10:10";

list($minutes, $seconds) = explode(':', $value);

$milliseconds = $seconds * 1000 + $minutes * 60000;

var_dump($milliseconds); // 610000
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜