|
-
Jun 17th, 2001, 06:47 PM
#1
Thread Starter
Hyperactive Member
Welcome!
I want to welcome the user on my website depending on the current time.
I.e. it's 03:00 in the morning - a textline "Good Morning!" should be drawn by a script.
When it's 12:00 then it should say "Good Day!" and at 20:00 it should say "Good Evening!".
thx in advanced!
-
Jun 17th, 2001, 08:11 PM
#2
Fanatic Member
Code:
<script>
var today = new Date();
var hours = today.getHours();
if (hours == 3) document.write("Good morning!");
else if (hours == 12) document.write("Good day!");
else if (hours == 20) document.write("Good evening!");
</script>
Alcohol & calculus don't mix.
Never drink & derive.
-
Jun 17th, 2001, 08:32 PM
#3
Fanatic Member
P.S. If you want a range of hours, then just use < and >. For example,
Code:
<script>
var today = new Date();
var hours = today.getHours();
if (hours <= 12) document.write("Good morning!");
else if (hours <= 20) document.write("Good day!");
else document.write("Good evening!");
</script>
Alcohol & calculus don't mix.
Never drink & derive.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|