I want to convert milliseconds to a human readable string.
So it looks something like 1:59:23 (1 hour, 59 minutes, 23 seconds).
I’ve tried this:
int hours = (metaData["duration"].toInt()/(1000 * 60 * 60));
int mins = (metaData["duration"].toInt()/(1000 * 60));
int seconds = (metaData["duration"].toInt()/1000);
But this just gives out the total, ie, it will say the total amount of mins and total amount of seconds, it does not take in to account that 60 seconds becomes a minute, so do not include it in the seconds count.
Does anyone have a way to do this?
Thanks
You need to use the modulus function to extract how many minutes and seconds there are.
The modulus function returns the remainder when divided by something. So, using
% 60you end up with the number of seconds there are, ignoring full minutes, and likewise for minutes.