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? Link to comment https://forums.phpfreaks.com/topic/212734-milliseconds-to-minsec/ 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); Link to comment https://forums.phpfreaks.com/topic/212734-milliseconds-to-minsec/#findComment-1108151 Share on other sites More sharing options...
The Little Guy Posted September 7, 2010 Author Share Posted September 7, 2010 Thanks Link to comment https://forums.phpfreaks.com/topic/212734-milliseconds-to-minsec/#findComment-1108387 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.