Alright, so I send an integer to my mysql database that's in milliseconds. Now, I'm trying to make it so that it says: Time Played: 1 day 3 hours and 15 minutes. But I'm having a hard time doing it, I just am able to get the minutes days and hours, but it'd be the amount of hours total the amount of days total and the minutes total, not all in one. I have my code like this:
$time = $timeRow['time'];
$seconds = floor($time / 1000);
$minutes = floor($seconds / 60);
$hours = floor($minutes / 60);
$days = round($hours / 24);
$milliseconds = $time % 1000;
$seconds = $seconds % 60;
$minutes = $minutes % 60;
echo'Time Played: '.$days.' days '.$hours.' hours '.$minutes.' minutes';
Could anyone help me fix this up?
<?php
$time = $timeRow['time'] / 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'Time Played: '.$days.' days '.$hours.' hours '.$minutes.' minutes '.$seconds.' seconds';