<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
setInterval(() => {
let a;
let time;
let date;
const options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
a = new Date();
date = a.toLocaleDateString(undefined, options)
time = a.getHours() + ':' + a.getMinutes() + ':' + a.getSeconds() ;
document.getElementById('time').innerHTML = time + ' on ' + date;
}, 1000);
</script>
</head>
<body>
current time is : <span id="time"></span>
</body>
</html>
Output
13:45:11 on Friday, November 27, 2020
Comments
Post a Comment