datetime - How can I convert milliseconds to "hhmmss" format using javascript? -


i using javascript date object trying convert millisecond how many hour, minute , second is.

i have currenttime in milliseconds

var currenttime = new date().gettime() 

and have futuretime in milliseconds

var futuretime = '1432342800000' 

i wanted difference in millisecond

var timediff = futuretime - currenttime 

the timediff was

timediff = '2568370873' 

i want know how many hours, minutes, seconds is.

could help?

var secdiff = timediff / 1000; //in s var mindiff = timediff / 60 / 1000; //in minutes var hdiff = timediff / 3600 / 1000; //in hours   

updated

function mstohms( ms ) {     // 1- convert seconds:     var seconds = ms / 1000;     // 2- extract hours:     var hours = parseint( seconds / 3600 ); // 3,600 seconds in 1 hour     seconds = seconds % 3600; // seconds remaining after extracting hours     // 3- extract minutes:     var minutes = parseint( seconds / 60 ); // 60 seconds in 1 minute     // 4- keep seconds not extracted minutes:     seconds = seconds % 60;     alert( hours+":"+minutes+":"+seconds); }  var timespan = 2568370873;  mstohms( timespan );   

demo


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -