The main problem with converting milliseconds to hours, minutes, and seconds is that they are not always consistent. For example, if you convert 10,000 milliseconds to hours, the result would be 10 hours. However, if you converted 10,000 milliseconds to minutes, the result would be 10 minutes and 40 seconds.
var date = new Date(milliseconds); var hh = date.getHours(); var mm = date.getMinutes(); var ss = date.getSeconds();
This code creates a new date object using the given milliseconds, then gets the hours, minutes, and seconds from that date object.
var now = new Date(); // 12/5/2015 3:00 PM
You can also use the built-in Date.now() function.
var now = Date.now(); // 12/5/2015 3:00 PM