Connecting Tech Pros Worldwide Forums | Help | Site Map

date periods?

Dave Turner
Guest
 
Posts: n/a
#1: Dec 22 '05
Id like to be able to add text to my site but have it only saying that for a
couple of months. Is this easy to do?



Fred Forsyth
Guest
 
Posts: n/a
#2: Dec 22 '05

re: date periods?


So you want to have some text displayed up until a specified date? If
so, this will do it:

<? if (mktime() < mktime (0,0,0,1,1,2006)) echo "hello"; ?>

If the current date is before the 1st Jan 2006, then show the text.
Otherwise don't.

Hope that helps,
Fred.

NC
Guest
 
Posts: n/a
#3: Dec 22 '05

re: date periods?


Dave Turner wrote:[color=blue]
>
> Id like to be able to add text to my site but have it only saying that
> for a couple of months. Is this easy to do?[/color]

Yes. There are many ways of doing it. One example:

$date = 'February 22, 2006';
if (time() < strtotime($date)) {
echo "This is the text that should appear before $date";
} else {
echo "This is the text that should appear after $date";
}

Cheers,
NC

Closed Thread