JavaScript comes prebuilt with several objects for you to use.
One of the objects is the Date() object.You can use the Date()
object to display the user's computer day and time.
Here's how you go about it:
<script>
var currentTime = new Date();
//Get the hour
var hours = currentTime.getHours();
// Get the minutes
var minutes = currentTime.getMinutes();
// Get the seconds
var seconds = currentTime.getSeconds();
// Let's print the the time using our variables
window.document.write(hours + ":" + minutes + ":" + seconds);
</script>