-1

I am working on a basic website. I however need a bit of help.

I am wondering if it's possible to alter the screen colour of my website to match the current time.

For example, if the sun has set and it's 8PM then I would like the colours to go warm so you get a hazy type of orange. When the sun rises again I would like the colour to return back to normal.

I would like to do this using Javascript.

Is there anyway I could involve the computers clock to check on the time and if the time is after 8PM for example, it will change the colour of the site to a warmer colour?

Paulie_D
  • 107,962
  • 13
  • 142
  • 161
  • 1
    Welcome to Stack Overflow! It is expected that you at least attempt to code this for yourself. Stack Overflow is not a code writing service. I would suggest that you do some additional research, either via Google or by searching SO, make an attempt and. if you still have trouble, come back with **your code** and explain what you have tried and why it did not work. – Paulie_D May 06 '16 at 09:35
  • Please review [**How to ask**](http://stackoverflow.com/help/how-to-ask) questions on Stack Overflow and what types of questions [**can be asked**](http://stackoverflow.com/help/on-topic) and what types [**should be avoided.**](http://stackoverflow.com/help/dont-ask) – Paulie_D May 06 '16 at 09:36
  • Possible duplicate of [Changing background based on time of day (using javascript)](http://stackoverflow.com/questions/4358155/changing-background-based-on-time-of-day-using-javascript) – Aaron May 06 '16 at 09:39

1 Answers1

-1

This should not be to difficult to find on yourself but i will give some tips to get you started:

You can change the classname of an item with following code:

document.getElementById("MyElement").className = "MyClass";

now just make 2 different styles in your css depending on what time of day it is.

To find out the current time you can use the following code:

var currentdate = new Date();
currentdate.getHours();

Check the documentation for more info on the date object in javascript.

This should get you started. Happy coding!

ThomasS
  • 705
  • 1
  • 11
  • 30