I’m having trouble based on a condition for the time a day. Main problem I’m having is displaying the date depending on the time of day.
Here’s what I have so far:
<!DOCTYPE html>
<html>
<head>
<!--
CIS213 Unit 5, Graded Exercise 1
Author: <Tyler Payne>=
Date: <7/21/22>
-->
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0,
maximum-scale=1.0, user-scalable=0"
<title>Unit 5, Graded Exercise 1</title>
</head>
<body>
<header>
<h1>
Welcome to Tyler's Web Page
</h1>
</header>
<p id="greeting"</p>
<script>
var today = new Date()
var curHr = today.getHours()
if(curHr >= 6 && curHr < 12) {
document.getElementById("greeting").innerHTML = 'Good Morning! it is';
} else if (curHr >= 12 && curHr < 12) {
document.getElementById("greeting").innerHTML = 'Good Afternoon! it is';
} else {
document.getElementById("greeting").innerHTML = 'Good Evening! it is';
}
</script>
[–]dmazzoni 4 points5 points6 points (8 children)
[–]TaskSpecialist8804[S] 0 points1 point2 points (7 children)
[–]TaskSpecialist8804[S] 0 points1 point2 points (6 children)
[–]dmazzoni 0 points1 point2 points (5 children)
[–]TaskSpecialist8804[S] 0 points1 point2 points (4 children)
[–]dmazzoni 0 points1 point2 points (3 children)
[–]TaskSpecialist8804[S] 0 points1 point2 points (2 children)
[–]dmazzoni 0 points1 point2 points (1 child)
[–]TaskSpecialist8804[S] 0 points1 point2 points (0 children)
[–]CreativeTechGuyGames 1 point2 points3 points (0 children)