This code calculates the number of seconds elapsed between two dates. The division by 1000 occurs because the method getTime()returns a value measured in milliseconds.
The code is actually unnecessarily long. To get the milliseconds that have elapsed between two objects Date, you can simply use the operator -for yourself Date:
var start = new Date();
// Some code that takes some time
var end = new Date();
var secondsElapsed = (end - start) / 1000;