display hour and minute in javascript code example
Example 1: get current time in js
<script>
var today = new Date();
var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
</script>
Example 2: how to show only time in hours and minutes only in javascript
function prettyDate2(time) {
var date = new Date(parseInt(time));
return date.toLocaleTimeString(navigator.language, {
hour: '2-digit',
minute:'2-digit'
});
}