Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Time Greeting Re: Time Greeting

#78211
Pete Oxenham
Member

I agree with the two above posts, it should be generated with Javascript

Javascript:

Code:
window.onload = function () {
timegreeting();
}

function timegreeting() {
var now = new Date();
var greet;
/* If before 11:00 */
if (now.getHours() < 11) { greet = "

Good morning!

“;
}
/* If between 11:00 and 17:00 (5:00, all times are expressed in 24 hr time) */
else if (now.getHours() < 17) { greet = "

Whatever

“;
}
/* If after 17:00 */
else {
greet = “

Good evening!

“;
}
document.getElementById(“greeting”).innerHTML = greet;
}

HTML:

Code:

I used that script a long time ago, but it seems to work well