0

Before i asking, i watched this answer https://stackoverflow.com/a/19680778/11011981
the code that i used is this

function secondsToTime($seconds) {
$dtF = new \DateTime('@0');
$dtT = new \DateTime("@$seconds");
return $dtF->diff($dtT)->format('%a days, %h hours, %i minutes and %s seconds');
}

but the problem was....if the data we use is "1640467" result is
18 days, 23 hours, 41 minutes and 7 seconds

but, my data isn't that big. sometimes it only "964" and if using that code. the result was
0 days, 0 hours, 16 minutes and 4 seconds

can i make it somehow it only show the format that has data on it? example if my result is
0 days, 0 hours, 16 minutes and 4 seconds
i want the empty 0 days, 0 hours to be hidden.... anyone know how to do it?

thanks... i stuck on this since this morning lol

0 Answers0