July 18, 201115 yr Hey, Basically i'm making something for a gaming communuity, who have a database which holds info from their servers. The one thing i'm stuck on is this: All players have a "total connection time", however the number stored in the database is of a unix 32 bit timestamp. Now, I know the php date/time function can convert this, but I want it in a certain format that I cant work out. Heres an example: Connection Time 32 bit = 212675 Needs to be converted to = 2d 11:04:35h Thats what the stats website provides, but I need to work out how to convert it myself. Anyone got a clue?
July 18, 201115 yr Are you using PHP 5.3? $d1 = new DateTime(); $d2 = new DateTime(); $d2->add(new DateInterval('PT212675S')); $interval = $d2->diff($d1); echo $interval->format('%dd %H:%I:%Sh'); Edited July 18, 201115 yr by Jock
July 18, 201115 yr ****ty simple $days = (int) ($time / 86400.0); $time -= $days * 86400; $hours = (int) ($time / 3600.0); $time -= $hours * 3600; $minutes = (int) ($time / 60.0); $time -= $minutes * 60; $seconds = $time; echo "{$days}h {$hours}:{$minutes}:{$seconds}";
July 18, 201115 yr Author Ah thanks Jock, yours worked perfect Although cepa im sure that worked although I wasnt sure how to implement the number xD Thanks, you guys saved me again
Create an account or sign in to comment