The following code displays the date and time in Javascript
<script type="text/javascript">
// Display date and time
var date = new Date();
document.write(date);
</script>
Output
Sun Jul 25 2021 03:20:44 GMT+0100 (British Summer Time)
If you wanted to grab the hours, minutes, seconds and year individually you could assign these to their own variables by using the getHours(), getMinutes(), getSeconds() and getFullYear() methods
<script type="text/javascript">
// Display hours, minutes, seconds, year
var date = new Date();
var hours = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
var year = date.getFullYear();