PenAndPapers PenAndPapers - 3 months ago 8
PHP Question

PHP convert integer to time

How can I convert integer to time in minutes e.g.

5
would give
30mins
. I've tried

<?php
$toMin = 5;
echo date('i', ($toMin*60)).'mins';
?>


But it only returns
05mins

Answer

so something like:

$time='7.5'; //, 8.3, 2.2. 

$x=explode('.',$time);

$min=60*($x[1]/10);

echo $x[0] .'hours and '.$min.'mins';