Find time difference between two DateTime in JavaScript

<script type="text/javascript">
//Start Time
var d1 = new Date();

// Do your operations

//End Time
var d2 = new Date();

//Time difference in milli seconds
document.write("Your Operation took  " + (d2.getTime() - d1.getTime()) + " milliseconds");

</script>