Timestamp calculation
I would like to calculate the difference between 2 timestamps. The timestamp is generated from the new Date() method and is formatted as hh:mm:ss in military time.
What needs to take place to calculate the difference between 2 timestamps?
Does the time stamp need to be converted to seconds to calculate the difference and then reconvert to the hh:mm:ss time format?
function militaryTime() {
// Get the time and format it
var digital = new Date();
var hours = digital.getHours();
var minutes = digital.getMinutes();
var seconds = digital.getSeconds();
//military format
if (hours <= 9) hours = "0" + hours;
if (minutes <= 9) minutes = "0" + minutes;
if (seconds <= 9) seconds = "0" + seconds;
var time = hours + ":" + minutes + ":" + seconds;
return time
}
alert(militaryTime());oes