1
faucess
How to change css depending on the time??
  • 2010/8/15 12:31

  • faucess

  • Just popping in

  • Posts: 2

  • Since: 2010/4/26


Hello,

First, apologize for my English hehe.

I'm trying to change the css of a theme depending on time of day. I entered the following code on theme.html but I get errors.
Someone could help me?

<link rel="stylesheet" type="text/css" media="all" href="
<?php  $hour date('H');  
if ((
$hour >= 6) and ($hour <= 19))  
{
echo 
"<{$xoops_imageurl}>css/blue.css"
}  
else  
{     
echo 
"<{$xoops_imageurl}>css/red.css"
?> 
" />


I tried to do work in several ways, but I can not.

Thank you very much for your time.

2
playsome
Re: How to change css depending on the time??
  • 2010/8/15 13:44

  • playsome

  • Not too shy to talk

  • Posts: 197

  • Since: 2009/4/15


Hello,

Interesting idea, change the theme depending on time of day.

Although I do not know how you would do this in PHP I have found a javascript which may do it.

<SCRIPT LANGUAGE="JavaScript">
<!-- 
Begin
function getCSS()
{
datetoday = new Date();
timenow=datetoday.getTime();
datetoday.setTime(timenow);
thehour datetoday.getHours();

if (
thehour 20)
display "tree_twilight.css";
else if (
thehour 17)
display "tree_sunset.css";
else if (
thehour 14)
display "tree_afternoon.css";
else if (
thehour 11)
display "tree_noon.css";
else if (
thehour 7)
display "tree_morning.css";
else if (
thehour 4)
display "tree_sunrise.css";
else if (
thehour 1)
display "tree_twilight.css";
else
display "tree_sunset.css";

var 
css '<';  css+='link rel="stylesheet" href=' display ' /';  css+='>';

document.write(css);
// End -->
}
</
script>
<
script language="javascript">getCSS();</script>


The code is from this website http://www.katgal.com/2007/03/time-sensitive-css-switcher-change.html.

I hope you get it working.

3
faucess
Re: How to change css depending on the time??
  • 2010/8/15 14:04

  • faucess

  • Just popping in

  • Posts: 2

  • Since: 2010/4/26


Great!

It works perfectly, thank you very much! You took the headache of several days hehe.

Greetings!

Login

Who's Online

154 user(s) are online (59 user(s) are browsing Support Forums)


Members: 0


Guests: 154


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits