I can’t actually take credit for this code. Unfortunately, I don’t remember where it originally came from; if you know where this came from, please let me know so I can give credit … where credit is due. Anyway, this javascript will welcome the user based on the time of day:
<script type=’text/javascript’>
var date=new Date(); // Gets the full date!
var day=date.getHours(); // Gets the hours!if(day<=11) {
document.write(‘Good Morning’); // If it’s before 12 PM then display this!
}
else if(day<18)
{
document.write(‘Good Afternoon’); // After 12 PM display this!
}
else
{
document.write(‘Good Evening’); // After 6 PM display this!
}
</script>, and Welcome to my blog.
This will tell the user Good morning, Good afternoon or Good evening depending on the time of day. I hope that helps someone.