We Recommend

Pro JavaScript Techniques Pro JavaScript Techniques
Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites. This book doesn't waste any time looking at things you already know, like basic syntax and structures.


Posted By

noah on 09/24/07


Tagged

time performance optimization profiling


Versions (?)


Who likes this?

2 people have marked this snippet as a favorite

vali29
korzhik


Get the time elapsed between two intervals


Published in: JavaScript 


  1. var foo = new Date();
  2. var bar = new Date();
  3. var baz = new Date();
  4. baz.setTime(bar.getTime() - foo.getTime());
  5. alert(baz.getMilliseconds() + " ms elapsed between the definition of foo and bar.");

Report this snippet 

You need to login to post a comment.