I have created a javascript that will display start and stop time when the user choose the option from dropdown menu, please some one help me how to calculate the time difference of stop and start time.(我创建了一个JavaScript,当用户从下拉菜单中选择选项时,它将显示开始和结束时间,请有人帮我如何计算停止和开始时间的时差。)
here is below code(这是下面的代码)
<script>
var myTime = new Date().toLocaleString(navigator.language, {
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
});
function getValue(data) {
var selectedText = $("#ddselect").find("option:selected").text();
if (selectedText != "None") {
var display = document.getElementById("display");
var newRow = display.insertRow(display.rows.length);
var cell1 = newRow.insertCell(0);
cell1.innerHTML = myTime;
var cell2 = newRow.insertCell(1);
cell2.innerHTML = selectedText;
/* stop time */
var stopTime = new Date().toLocaleString(navigator.language, {
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
});
var cell3 = newRow.insertCell(2);
cell3.innerHTML = stopTime;
var cell4 = newRow.insertCell(3);
cell4.innerHTML = stopTime - myTime;
}
}
</script>
ask by sanjiv kumar translate from so