How to convert a decimal into time, eg. HH:MM:SS

前端 未结 5 1057
栀梦
栀梦 2020-12-09 12:01

I am trying to take a decimal and convert it so that I can echo it as hours, minutes, and seconds.

I have the hours and minutes, but am breaking my brain trying to f

5条回答
  •  情话喂你
    2020-12-09 12:07

    I am not sure if this is the best way to do this, but

    $variabletocutcomputation = 60 * ($dec - $hour);
    $min = round($variabletocutcomputation);
    $sec = round((60*($variabletocutcomputation - $min)));
    

提交回复
热议问题