javascript Date().getTime() code example
Example 1: javascript get Time
var d=new Date();
d.getTime();//I'm in milliseconds, divide by 1000 for seconds
Example 2: get time in javascript
//HTML
<a onclick="timeNow(test1)" href="#">SET TIME</a>
//Javascript
function timeNow(i) {
i.value = new Date()
}
Example 3: getTime
var end, start;
start = new Date();
for (var i = 0; i < 1000; i++) {
Math.sqrt(i);
}
end = new Date();
console.log('Operation took ' + (end.getTime() - start.getTime()) + ' msec');