1 回答

TA貢獻(xiàn)1796條經(jīng)驗(yàn) 獲得超10個(gè)贊
是的,您可以使用 strtotime() 找到答案$time = date('H :i', strtotime($res)); 這就是我嘗試過(guò)的方法,
$connect = new mysqli($localhost, $username, $password, $dbname);
$sql = "SELECT AVG( TIMEDIFF( `created_at` , `updated_at` ) ) AS time_average FROM table";
$result = $connect->query($sql);
$row = $result->fetch_assoc();
$res = $row["time_average"];
//echo "avg".$res."<br/>";
$time = date('H :i', strtotime($res));
echo "time avarage : ".$time;
然后你可以使用 explode 方法來(lái)描述如下,
$timeArray =explode(":", $time);
echo $timeArray[0]."hrs ".$timeArray[1]."mins";
它工作正常,并認(rèn)為它會(huì)幫助你。
- 1 回答
- 0 關(guān)注
- 125 瀏覽
添加回答
舉報(bào)