我想除以整数类型,将已有的小数点四舍五入

I want to divide by the integer type and round off the existing decimal point

我想除以整数类型并截断小数点。 数据库列是整数

下面是代码

public static function time($time)
{
    $h = $time/60;
    floor($h);
    $m = $time%60;
    return $h . ':' . $m; 
}

$h用dd看到的时候是这样的

1.1666666666667

如何在小数点后截断?

您需要将 floor($h) 放入变量中。

尝试

public static function time($time)
{
    $h = $time/60;
    $h = floor($h);
    $m = $time%60;
    return $h . ':' . $m; 
}

或者为了简单起见[​​=13=]

public static function time($time)
{
    $h = floor($time/60);
    $m = $time%60;
    return $h . ':' . $m; 
}