D
D
Danil2017-06-03 12:26:41
Java
Danil, 2017-06-03 12:26:41

How to make a greeting depending on the time of day?

Hello. How to display a greeting depending on the time of day?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
freecoder-en, 2017-06-03
@freecoder-en

Basically a question of logic.
1. Track the location of the request
2. Find out what time of day is best for this request (Relative to the location)
3. Make your own greeting after receiving 1.2 data.
Voobshe question is problematic. Can be done in different ways.
To the question how? Differently .
The main thing is to write an algorithm that will track requests for a page.
Check out how to track page requests in Java Script.

S
St1mRiviera, 2018-12-30
@St1mRiviera

var h=(new Date()).getHours();
if (h > 3 && h < 7) document.writeln("Goodnight");
if (h > 6 && h < 12) document.writeln("Good morning");
if (h > 11 && h < 17) document.writeln("Good afternoon");
if (h > 16 && h < 24) document.writeln("Good evening");
if (h > 23 || h < 4 ) document.writeln("Good night");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question