請參閱php中的註釋。經過ETA計算,日期和時間顯示不正確。 (整體PHP代碼)
卡車車隊ETA計算器
距離在里程數:城市到B市
$dist_city_a_city_b = 475;
裝載/準備時間
$turnaround = 45;
出發時間
$departtime = date('Y-m-d H:i:s');
echo "Distance: $dist_city_a_city_b Kilometers<br>";
$distM = $dist_city_a_city_b*1000;
echo "Distance: $distM in meters<br>";
速度在千米每小時不變
$speed = 80/3.6;
echo "Speed: $speed converted to meters/second<br>";
$eta_1 = $distM/$speed;
echo "Distance/Speed: $eta_1<br>";
$eta = $eta_1/60;
echo "All in minutes = $eta<br>";
$arivaltime = $eta + $turnaround;
echo "Arriveal in minutes including turnaround: $arivaltime<br>";
echo "Depart Time: ".$departtime."<br>";
這裏下面是不顯示的問題日期計算後正確 需要下面的代碼顯示ETA在正確的格式添加的計算行進時間發車時間,也就是356.25分鐘,意思是如果在中午12:00移動,那麼它應該顯示當天日期和接近18:00,如果是23:00,則它應該移動到第二天日期和小時,這將是05:00
echo "Arrival Time: " . date('Y-m-d H:i:s', strtotime($arivaltime, strtotime($departtime))) . " (ETA)<br>";
其餘代碼將發佈到mysql表
輸出:
Distance: 475 Kilometers Distance: 475000 in meters Speed: 22.222222222222 converted to meters/second Distance/Speed: 21375 All in minutes = 356.25 Arriveal in minutes including turnaround: 401.25 Depart Time: 2015-05-21 23:53:03 Arrival Time: 1970-01-01 04:00:00 (ETA)
謝謝大家
SamimiIT
那麼它顯示的是什麼,而不是恰當的日期? – Kyle
已編輯!現在顯示輸出。最後一行ETA得到錯誤報告。 –