Hi Guys,

Newbie here to Javascript, this is a hobby that is fast getting out of control and I'm in over my head. So could do with a little help, so many thing's I want to try and do, yet can't seem to get this little function working lol

Basically I have a function that in my mind checks the time and if it is between 5am and 6pm will display a daytime background or a night time background if outside of those hours. There is a second set of amendments in the loop just to validate via text what should be outputted, but neither is.... scratching my head now, as I don't understand why it just doesn't work.

No errors according to my IDE, it just doesnt load a background, does that mean I'm stuck in limbo?

Here's my code:

Code:
<script>
// Dynamic Background for HTML5 template based on time of day.
function dynamicBG(){

	var d  = new Date();
	var h = d.getHours();
	
	if ((h <= 5) && (h >=18))
	{
		document.body.style.backgroundImage="url('images/assets/daytime-bg.jpg')";
		document.getElementById("bgText").innerHTML="The BG Should be Day Time";
		} else{
		document.body.style.backgroundImage="url('images/assets/nightTime-bg.jpg')";
		document.getElementById("bgText").innerHTML="The BG Should be Night Time";
		}
}

	window.onload = dynamicBG();
</script>
Thanks in advance for any help you can give.