Jump to content

image to time


boemboem

Recommended Posts

Hello all,

 

The code beneath should change the image on my homepage, but it doesn't, because the image didn't change at 8.00 this morning. (header1.jpg) and displayed header2.jpg

 

I know the code isn't completly clean, this is because the code was origin a if the else statement for $h < 7, $h  <12

 

Any help would be great.

 

<?php
$h = date('G'); //set variable $h to the hour of the day
//G is the date key for hours in 24 format (not 12), with no leading 0s, like 02.

if ($h = 1) $img = './style/header2.jpg';
if ($h = 2) $img = './style/header2.jpg';
if ($h = 3) $img = './style/header2.jpg';
if ($h = 4) $img = './style/header2.jpg';
if ($h = 5) $img = './style/header2.jpg';
if ($h = 6) $img = './style/header2.jpg';
if ($h = 7) $img = './style/header2.jpg';
if ($h =  $img = './style/header1.jpg';
if ($h = 9) $img = './style/header1.jpg';
if ($h = 10) $img = './style/header1.jpg';
if ($h = 11) $img = './style/header1.jpg';
if ($h = 12) $img = './style/header1.jpg';
if ($h = 13) $img = './style/header1.jpg';
if ($h = 14) $img = './style/header1.jpg';
if ($h = 15) $img = './style/header1.jpg';
if ($h = 16) $img = './style/header1.jpg';
if ($h = 17) $img = './style/header1.jpg';
if ($h = 18) $img = './style/header1.jpg';
if ($h = 19) $img = './style/header2.jpg';
if ($h = 20) $img = './style/header2.jpg';
if ($h = 21) $img = './style/header2.jpg';
if ($h = 22) $img = './style/header2.jpg';
if ($h = 23) $img = './style/header2.jpg';
else $img = './style/header1.jpg';
?>

Link to comment
Share on other sites

Ugh...

how about

$h = date('G'); //set variable $h to the hour of the day
//G is the date key for hours in 24 format (not 12), with no leading 0s, like 02.

if ($h > 7 && $h < 19) {
  $img = './style/header1.jpg';
} else {
  $img = './style/header2.jpg';
}

Link to comment
Share on other sites

Ugh...

how about

$h = date('G'); //set variable $h to the hour of the day
//G is the date key for hours in 24 format (not 12), with no leading 0s, like 02.

if ($h > 7 && $h < 19) {
  $img = './style/header1.jpg';
} else {
  $img = './style/header2.jpg';
}

 

LOL... I was gonna say that but I didn't wanna lose focus on the actual question =P

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.