Sinisterly
Change the CSS depending on the hour - Printable Version

+- Sinisterly (https://sinister.li)
+-- Forum: Design (https://sinister.li/Forum-Design)
+--- Forum: Web Design (https://sinister.li/Forum-Web-Design)
+--- Thread: Change the CSS depending on the hour (/Thread-Change-the-CSS-depending-on-the-hour)



Change the CSS depending on the hour - Oxyrus - 08-13-2015

Hello folks, I found this script on a Spanish blog today so I decided to translate it for you. Pretty much what it does is to change the CSS if it's day or night, but you are able to change it because it's really simple.

All you have to do is to copy the script within the head tags.

Code:
<script type="application/javascript"> changeDay = new Date(); hour = changeDay.getHours(); minutes = changeDay.getMinutes(); time = hour + "." + minutes; if (time >= 19.0 && hour < 23.59 || hour >= 0.0 && hour < 5.59) { document.write("<link rel='stylesheet' type='text/css' href='night.css' />"); } else if (hour > 6.0 && hour < 18.00) { document.write("<link rel='stylesheet' type='text/css' href='day.css' />"); } else { document.write("<link rel='stylesheet' type='text/css' href='day.css' />"); } </script>



RE: Change the CSS depending on the hour - Zodiac - 08-13-2015

This should be useful for some people, thanks for sharing. Smile


RE: Change the CSS depending on the hour - Kill - 08-13-2015

Oxyrus, why would You use this :3?


RE: Change the CSS depending on the hour - Oxyrus - 08-13-2015

(08-13-2015, 09:27 PM)Kill Wrote: Oxyrus, why would You use this :3?

To change your design from light to dark in day and night, or whatever, idk.


RE: Change the CSS depending on the hour - Quanity - 08-13-2015

MyBB skin. At morning itll be lighted
at night itll be dark theme Biggrin Tongue


RE: Change the CSS depending on the hour - Andrew_mybb_import13657 - 08-13-2015

(08-13-2015, 10:07 PM)Believer Wrote: MyBB skin. At morning itll be lighted
at night itll be dark theme Biggrin Tongue

Honestly I don't think that would look that good, but it's a good idea if you add a 'Nah I want night mode forever!' or 'I want day mode forever :noh: '


RE: Change the CSS depending on the hour - Kill - 08-13-2015

(08-13-2015, 07:21 PM)Pull Wrote: -
Honestly I don't think that would look that good, but it's a good idea if you add a 'Nah I want night mode forever!' or 'I want day mode forever :noh: '

That's easier :3


RE: Change the CSS depending on the hour - Andrew_mybb_import13657 - 08-13-2015

(08-13-2015, 10:47 PM)Kill Wrote:
(08-13-2015, 07:21 PM)Pull Wrote: -
Honestly I don't think that would look that good, but it's a good idea if you add a 'Nah I want night mode forever!' or 'I want day mode forever  :noh: '

That's easier :3

Why when you quoted me you made my name say "Pull" ? :angry:


RE: Change the CSS depending on the hour - Kill - 08-14-2015

(08-13-2015, 10:50 PM)0031 Wrote: Why when you quoted me you made my name say "Pull" ?  :angry:

Deleted wrong quotes,  :tongue:


RE: Change the CSS depending on the hour - Andrew_mybb_import13657 - 08-15-2015

(08-14-2015, 11:49 AM)Kill Wrote:
(08-13-2015, 10:50 PM)0031 Wrote: Why when you quoted me you made my name say "Pull" ?  :angry:

Deleted wrong quotes,  :tongue:

Oh, lol :noh: