javascript get current time 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 javascript
var d = new Date();
var n = d.toLocaleTimeString();
document.getElementById("timer").innnerHTML = n;
Example 3: current time in javascript
new Date().toLocaleString();
>> "09/08/2014, 2:35:56 AM"
Example 4: javascript current date time
var today = new Date().toLocaleDateString(undefined, {
day: '2-digit',
month: '2-digit',
year: 'numeric',
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
})
Example 5: get current time in js
<script>
var today = new Date();
var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
</script>
Example 6: javascript get current time
var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
console.log(date.toLocaleTimeString('en-US'));
console.log(date.toLocaleTimeString('en-GB'));