Converting milliseconds to minutes and seconds with Javascript

function millisToMinutesAndSeconds(millis) { var minutes = Math.floor(millis / 60000); var seconds = ((millis % 60000) / 1000).toFixed(0); return minutes + “:” + (seconds < 10 ? ‘0’ : ”) + seconds; } millisToMinutesAndSeconds(298999); // “4:59” millisToMinutesAndSeconds(60999); // “1:01” As User HelpingHand pointed in the comments the return statement should be: return ( seconds == 60 … Read more

Get current time in milliseconds using C++ and Boost

You can use boost::posix_time::time_duration to get the time range. E.g like this boost::posix_time::time_duration diff = tick – now; diff.total_milliseconds(); And to get a higher resolution you can change the clock you are using. For example to the boost::posix_time::microsec_clock, though this can be OS dependent. On Windows, for example, boost::posix_time::microsecond_clock has milisecond resolution, not microsecond. An … Read more