Converting Milliseconds into hh:mm:ss

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
REwingUK
Forum Commoner
Posts: 26
Joined: Wed Jul 29, 2009 8:46 pm

Converting Milliseconds into hh:mm:ss

Post by REwingUK »

Hi guys,

So i've pulled through the data from a sql database, and now i'm looking how to convert millieseconds into hh:mm:ss.

The millieseconds i pull through is 167392

Any help is appreciated.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Converting Milliseconds into hh:mm:ss

Post by pickle »

What is that number relative to? That's only 167 seconds.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
incubi
Forum Contributor
Posts: 119
Joined: Mon Dec 07, 2009 1:47 pm

Re: Converting Milliseconds into hh:mm:ss

Post by incubi »

On Google everywhere :)

Hours = Milliseconds / (1000*60*60)
Minutes = (Milliseconds % (1000*60*60)) / (1000*60)
Seconds = ((Milliseconds % (1000*60*60)) % (1000*60)) / 1000

Lee
Post Reply