Answer the question
In order to leave comments, you need to log in
How to make a user greeting depending on what time it is?
Hello!
It is necessary to implement the possibility that, depending on the time of the user of the site, he would display different text.
For example, at 2 pm: "Good afternoon"
At 9 pm: "Good evening"
At 2 am: "Good night"
At 6 am: "Good morning!"
I think you can implement this using the date class on js, I tried, but I didn’t succeed.
Answer the question
In order to leave comments, you need to log in
const hours = new Date().getHours()
const someDiv = document.getElementById('hello')
if hours >= 12 {
someDiv.innerHTML = "Добрый день"
} else if hours ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question