javascript take time code example
Example 1: time taken for a function javascript
console.time("timer");
console.timeEnd("timer");
Example 2: javascript get time
var time = new Date();
time.getDate();
time.getDay();
time.getFullYear();
time.getHours();
time.getMinutes();
time.getSeconds();
time.getMilliseconds();
time.getTime();
time.toDateString();
time.toLocaleString();
time.toLocaleTimeString();
time.toLocaleDateString();
Example 3: javascript time execution
var t0 = performance.now();
doSomething();
var t1 = performance.now();
console.log("Call to doSomething took " + (t1 - t0) + " milliseconds.");
Example 4: javascript get Time
var d=new Date();
d.getTime();
Example 5: get time in javascript
<a onclick="timeNow(test1)" href="#">SET TIME</a>
function timeNow(i) {
i.value = new Date()
}