answersLogoWhite

0

The easiest way is to use JavaScript's native Date object. That object has a method called 'getTime()' that returns the number of milliseconds since the Unix epoch (Midnight, 1 January 1970, UTC)

To determine how long between two separate events, you'd simply set a pair of variables at the start and the end, and then do the math. This will return the number of milliseconds between the setting of the two variables.

var dateA = new Date().parse('March 21, 2012');

/*thing you want timed goes in here*/

var dateB = new Date().parse('July 15, 2012');

var difference = dateA - dateB;

//difference will now contain 10022400000

You will certainly want to turn that into a more readable format. See the related JSFiddle for complete code on how to work with this object.

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

How do you calculate the four number game ducci in java script?

To calculate the four number game in javaScript ..... I assume you are asking how to calculate the total of the 4 numbers? A simple function calculating the array (assuming you are using an array) is the easiest way. function calculate(array) { var total = 0; for (var counter = 0; counter < array.length; counter = counter + 1) { total = total + array[counter]; } return total; }


What two values you have to calculate speed?

Total distance and total time.


What is total distance and total time used to calculate?

Average speed.


How do you find total distance and total time and then calculate them altogether?

Total Distance: Distance from some fixed point at end - Distance from the same fixed point at start. Total Time: Time at end - Time at start. Not sure what is meant by "calculate them altogether".


How do you calculate the average speed of a swimmer?

The same way you calculate the average speed of any object. You divide distance by time.


How do you calculate total time for a job?

i donnt knoww .?


Which of the following do you calculate when you divide the total distance traveled by the total traveled time?

Speed = Distance/Time


What two quantities do you need to know how to calculate average speed?

To calculate average speed, you need to know the total distance traveled and the total time taken to cover that distance. The average speed is then determined by dividing the total distance by the total time. The formula is: average speed = total distance / total time.


What two pieces of information are required to calculate average velocity?

To calculate average velocity, you need the total displacement of the object and the total time it took to cover that displacement.


How to calculate the average speed of a bus?

To calculate the average speed of a bus, you would need to determine the total distance traveled by the bus and the total time it took to cover that distance. Divide the total distance by the total time to get the average speed. This formula is Average Speed = Total Distance / Total Time.


How do you calculated average speed?

you calculate average speed by dividing the total distance to the total time.


How do you calculate machine utilization rate?

normal working time divided by total working time.