PHP;距离和速度的时间换算

PHP; time conversion form distance and speed

我在转换从速度和距离得到的时间时遇到问题,这是我的代码;

$dist = 30; // Distance which is in kilometres(km)
// speed is in knots(kt), if I take speed of 40kt and convert it into kilometres(km/h) ... 40 * 1.852 = 74.08
$time = ($dist / 74.08) / 24;

// result is 0.016873650107991 which is correct, but my problem is how can this be format in H:m:s,
// tried with date('h:m:s', strtotime($time) but result is always 01:01:00 no mater the distance
echo $time;

有什么想法可以将时间格式化为 H:m:s 或改进此代码吗? 我搜索了堆栈但没有发现类似的问题,如果我错过了重复的抱歉,但是 link 非常欢迎。

这可能有帮助,

$dist = 10; // Distance which is in kilometres(km)
// speed is in knots(kt), if I take speed of 40kt and convert it into kilometres(km/h) ... 40 * 1.852 = 74.08
$time = ($dist / 74.08);

echo gmdate("H:i:s", $time * 3600);

这也适用于小时数 > 24 的情况

$dist = 10; // Distance which is in kilometres(km)

$ts = ($dist / 74.08) * 3600; // in seconds

$h = floor($ts/3600);
$m = floor(($ts / 60) % 60);
$s = $ts % 60;

echo "$h:$m:$s";