Jump to content

Image change with time


PartyRing

Recommended Posts

Ive got this php code which changes an image at a specific server time:

 

 

<?php

$timeOffset = + 0; // in hours, positive or negative

$nowHour = date("H", time() + (3600 * $timeOffset)) ;

 

if ($nowHour >= 16 && $nowHour < 0)

$message = '<img src="image1">';

else if ($nowHour >= 0 && $nowHour < 6)

$message = '<img src="image2">';

else if ($nowHour >= 6 && $nowHour < 17)

$message = '<img src="image3">';

else $message = '<img src="otherimage">';

print($message);

 

?> 

 

And it works, i think, but theres a time problem, can anyone help or work out whats wrong?

Link to comment
Share on other sites

Well, i imported it into my page, so that a daytime/nighttime image comes up according to the time of day.

 

I think theres either a problem with the server times, so it doesnt know what time it is, therefore goes to the default image.

OR

Its the crossover times, because at the point its sopposed to change where the > and < times are the same, it also defaults.

 

If you don't understand, please tell me and ill try and explain further  :)

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.