Lux05 Posted June 24, 2020 Share Posted June 24, 2020 (edited) Hi, Dose someone know how to change the output to "Days, Hours, Minutes, Seconds," instead of only Seconds? echo '<div style="float:right;width:60%;color:#666666">'. TeamSpeak3_Helper_Convert::version($ts3->virtualserver_uptime) .'</div>'; Edited June 24, 2020 by Lux05 Quote Link to comment https://forums.phpfreaks.com/topic/310988-how-to-change-seconds-into-days-hours-minutes-seconds/ Share on other sites More sharing options...
requinix Posted June 24, 2020 Share Posted June 24, 2020 Quote Link to comment https://forums.phpfreaks.com/topic/310988-how-to-change-seconds-into-days-hours-minutes-seconds/#findComment-1579108 Share on other sites More sharing options...
Barand Posted June 24, 2020 Share Posted June 24, 2020 One way is... $secs = 350000; $dt1 = new DateTime(); $dt2 = (clone $dt1)->add(new DateInterval('PT'.$secs.'S')); $diff = $dt1->diff($dt2); echo $diff->days . ' : ' . $diff->format('%h : %i : %s').'<br>'; //-> 4 : 1 : 13 : 20 1 Quote Link to comment https://forums.phpfreaks.com/topic/310988-how-to-change-seconds-into-days-hours-minutes-seconds/#findComment-1579112 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.