¿Cómo los sumo manteniendo el formato timestamp?
var a = 1391483052; // 00:04:12
var b = 2783115185; // 17:35:34
var suma = a + b; // 20:39:46
"Suma" debería mostrar 17:39:46
Código Javascript:
Ver original
// Funciones getHumanFormat = function( timeStamp ) { /** * To Miliseconds * timeStamp * 1000 */ var date = new Date( timeStamp * 1000 ); // Math.round( +new Date() / 1000 ); // Hours var hours = date.getHours(); console.log( "Horas", hours ); // Minutes var minutes = date.getMinutes(); // Seconds var seconds = date.getSeconds(); //console.log( hours, minutes, seconds ); // Check var hours = ( hours < 10 ) ? "0" + hours : hours ; var minutes = ( minutes < 10 ) ? "0" + minutes : minutes ; var seconds = ( seconds < 10 ) ? "0" + seconds : seconds ; // Human Format var formattedTime = hours + ':' + minutes + ':' + seconds; // Return formattedTime; return formattedTime; }; getTimeStampFormat = function( human ) { var timeStamp = 0; var date; // Check ":" /*if( human !: ) { return false; }*/ // Example // var human = '23:12:00'; date = new Date(); var a = parseInt( human.substr(0, 2) , 10); // Hours var b = parseInt( human.substr(3, 2) , 10); // Minutes var c = parseInt( human.substr(6, 2) , 10); // Seconds var d = 0; // Miliseconds date.setHours( a, b, c, d ); // console.log("=>", c ); timeStamp = ( date.getTime() / 1000 ); return timeStamp; };