【发布时间】:2020-11-14 05:23:54
【问题描述】:
我在转换从速度和距离获得的时间时遇到问题,这是我的代码;
$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 或改进此代码? 我已经搜索堆栈但没有发现类似的问题,如果我错过了重复抱歉,但链接非常受欢迎。
【问题讨论】:
-
时间格式以秒为单位消耗
0.016873650107991。您需要使用h:i:s。 -
也试过了,还是一样.. 01:00:00
-
您的具体问题是什么?