I have an $.ajax request and am saving the start time, and end time (using new Date().getMilliseconds()
). I see a weird occurrence where sometimes I subtract startTime
from endTime
and get a negative number.
(function(){
var startTime = new Date().getMilliseconds();
$.ajax({
url:"/url.php",
data: someObject,
method: "POST",
complete:function(r){
var endTime = new Date().getMilliseconds();
console.log(endTime - startTime); // sometimes negative?!
}
});
})();
Could someone please explain this? I'm sure there's a logical explanation aside from a rip in the space-time continuum.
(If there's a better way to measure this, that'd be appreciated too!)