how to take current time in javascript code example

Example 1: javascript get current time

var today = new Date();
var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();

Example 2: get current time in js

<script>

var today = new Date();

var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();

</script>

Example 3: calculate today date javascript

var today = new Date();

Example 4: get time in javascript

//HTML
<a onclick="timeNow(test1)" href="#">SET TIME</a>
//Javascript
function timeNow(i) {
  i.value = new Date()
}