I need to convert milliseconds to dates times(It depends). For example 14800000 milliseconds (14800 seconds) it becomes
4 hours, 6 minutes - not 4 hours, 6 minutes, 40 seconds
If it's 21 seconds, then you should say only "21 seconds"
I tried it with Datetime, but it never worked. That's why I ask but without DateTime. Thee data that must be: years, months, weeks, days, hours, minutes and seconds (single and plural)
like this code:
$milliseconds = '183547165';
$time = $milliseconds / 1000;
$days = floor($time / (24*60*60));
$hours = floor(($time - ($days*24*60*60)) / (60*60)); $minutes = floor(($time - ($days*24*60*60)-($hours*60*60)) / 60); $seconds = ($time - ($days*24*60*60) - ($hours*60*60) - ($minutes*60)) % 60;
echo $days.' days<br>'.$hours.' hours<br>'.$minutes.' minutes<br>'.$seconds.' seconds'; ?>
I have a hard time doing that. How do I do it?? Can you help me??