Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I calculate a duration time?

I am developing a web-based application to capture start time and end time from system date-time but my main problem is that I don't know how can I get the duration time, between start and end time for downtime.

 //Function to get current start time   var startTime = setInterval(function () { start() }, 1000);    function start() {     var startDate = new Date();     var timeStart = startDate.toLocaleTimeString();   $("#setCount").html(timeStart);  } 
like image 821
Ibonesh Avatar asked Mar 19 '13 07:03

Ibonesh


People also ask

What is a time duration?

Duration is how long something lasts, from beginning to end. A duration might be long, such as the duration of a lecture series, or short, as the duration of a party. The noun duration has come to mean the length of time one thing takes to be completed.

How do I calculate time duration in Excel?

Another simple technique to calculate the duration between two times in Excel is using the TEXT function: Calculate hours between two times: =TEXT(B2-A2, "h") Return hours and minutes between 2 times: =TEXT(B2-A2, "h:mm") Return hours, minutes and seconds between 2 times: =TEXT(B2-A2, "h:mm:ss")

Which is an example of time duration?

Duration is defined as the length of time that something lasts. When a film lasts for two hours, this is an example of a time when the film has a two hour duration. An amount of time or a particular time interval. A measurement of a bond's price sensitivity to changes in interest rates.


1 Answers

Do you mean this:

var date1 = new Date(); var date2 = new Date(); var diff = date2 - date1; //milliseconds interval 

upd

check JSFiddle

like image 175
Sergio Avatar answered Sep 22 '22 10:09

Sergio