The Little Guy Posted September 7, 2010 Share Posted September 7, 2010 I have a duration column in my database, which looks like this: 256574.69387755 it holds the duration of a song, how do I convert that number to a time? I am not sure what the time comes out to but I would like it formated: min:sec example: 4:10 how would I convert that? to get the minutes I thought I could do this: $min = $row['duration'] % 60; but that doesn't work any suggestions on how to get the minutes and the seconds? Quote Link to comment Share on other sites More sharing options...
btherl Posted September 7, 2010 Share Posted September 7, 2010 Try this: print "Duration: " . floor($row['duration'] / 60) . ":" . floor($row['duration'] % 60); If your values really are in around 250k in size, you might need to divide by 1000 as well to get the values you want. Edit: Just re-read your question properly. Try this: print "Duration: " . floor($row['duration'] / 60000) . ":" . floor(($row['duration'] / 1000) % 60); Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted September 7, 2010 Author Share Posted September 7, 2010 Thanks Quote Link to comment 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.