Write a JavaScript program to display the current day and time in the following format.
Sample Output:Today is: Tuesday.
Current time is: 10 PM: 30:38
<!DOCTYPE html>
<html>
<head>
<title>Current Day and Time</title>
</head>
<body>
<h1>Current Day and Time</h1>
<p id="time"></p>
<script>
function displayTime() {
const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
const currentDate = new Date();
const day = days[currentDate.getDay()];
let hours = currentDate.getHours();
let minutes = currentDate.getMinutes();
let seconds = currentDate.getSeconds();
let ampm = 'AM';
let timeString = `Today is: ${day}.\nCurrent time is: ${hours} ${ampm}: ${minutes}:${seconds}`;
if (hours >= 12) {
hours -= 12;
ampm = 'PM';
}
if (hours === 0) {
hours = 12;
}
document.getElementById('time').innerHTML = timeString;
}
setInterval(displayTime, 1000);
</script>
</body>
</html>
Output: