PDA

View Full Version : [PHP] Help



-paul.
21-12-2010, 06:39 PM
Hey Im working on a website and im trying to make the banner change at a time of the day


<? if(date(H) < 18 && date(H) > 6){
echo "<img src="image link">";
}else{
echo "<"img src="image link">";
}
?>

Thats my code but it doesnt seam to like it

anyone see anything?

LMS16
21-12-2010, 06:43 PM
<? if(date("H") < 18 && date("H") > 6){
echo "<img src=\"image link\">";
}else{
echo "<img src=\"image link\">";
}
?>

Need the quote marks :)

Lew.

-paul.
21-12-2010, 07:01 PM
Thanks alot (+ rep) One more question - Thats saying if its before 6:00PM and after 6:00AM then show a certain image then if its after 6PM show another - its now 7:01PM and its showing the wrong picture?

Joe!
21-12-2010, 07:34 PM
You might want to check that your server is set to the correct time then.
You could check the hour by simply echoing your date("H").

LMS16
21-12-2010, 07:42 PM
Add

<php date_default_timezone_set("Europe/London"); ?>

This will set the time of the script to GMT (UK Time)

Lew.

Want to hide these adverts? Register an account for free!