Jump to content

Recommended Posts

You need to manipulate the date() function.

 

 

G  24-hour format of an hour without leading zeros  0 through 23

 

This may be helpful as well to check to see if it's day or night:

 

A  Uppercase Ante meridiem and Post meridiem  AM or PM

 

And a numerical representation of the day of the week:

 

w  Numeric representation of the day of the week  0 (for Sunday) through 6 (for Saturday)

you would need a basic IF statement and date() function. here is a basic example:

 

$date = date("m/d/Y")

if($date == "12/23/08")
{
show this image
}
elseif($date == "12/24/08")
{
show this image
}
else
{
nothing to show
}

 

 

look into the date function, it is capable of doing time and days of the week to check against.

Well I am wanting to show an alert on my website at certain times each day. I need it to show up between 2 and 3 am, 10 and 11 am and 2 and 3 pm.

 

I don't really know PHP much at all, so I don't know how to edit much, really. :(

No one is just going to write it for you but I will help give you a start:

 

$time_now = date("H"); \\puts it in 24 hour formate
$

if($time_now == 2 || $time_now == 14) \\if the time is 2 am or pm
{
echo "It is 2 o'clock!";
}
elseif($time_now == 10)
{
echo "It is 10 am!";
}
else
{
echo "it isn't 10 or 2";
}

 

check out this page on php date http://www.tizag.com/phpT/phpdate.php

Could you use a cron job  to change the one picture source?

 

You don't need a cron job.  The only time someone is going to see it is when they get to the site.  So all you need to do is modify ngreenwood's code to fit your needs.

 

Why don't you try it, and if you still can't get it to work, come back with more questions?  Usually if you show some effort we're willing to help a lot more.

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.