[FONT=Arial]I have some text, and I want it to appear and disappear on a certain date? For example, if I had this on a website - By December 1, 2005, email me your ideas Can PHP remove "By December 1, 2005, email me your ideas" after the date without manually taking it off myself? If so, where can I find code examples?[/FONT]
if (time() < mktime(0, 0, 0, 12, 1, 2005)) {
echo "By December 1, 2005, email me your ideas";
}
time() returns the current unix timestamp and mktime creates a unix timestamp from the time and date entered in the args.
What is 0, 0, 0, - The time if needed?
####
Check out www.php.net/mktime for your answer
Ok I see. I'm terrible with if and else statements. I'm trying to make it appear and disappear on two different dates - Example appear on November 1 and disappear on December 1. What you gave is working but can't figure out how to make it disappear. I tried two if statements - the one you gave me and one with > and the date but no luck what do you suggest?
yes u make 2 if statements, then go to php manual and learn how to use mktime to make the other date, the code he gave you, does dissappear after the date.
This is a script to include a file depending on the time of day. You can easily change it for date rather than time. You could also echo text rather than do includes.
<?php $now = date("H i s"); if ($now < ('12 00 00')) {include('greetam.php');} elseif ($now > ('12 00 00')& $now < ('17 00 00')) {include('greetpm.php');} elseif ($now > ('17 00 00')) {include('greeteve.php');} ?>
Thanks guys.
I ended up using this
if (time() > mktime(0, 0, 0, 11, 1, 2005) & time() < mktime(0, 0, 0, 12, 1, 2005)) { echo "By December 1, 2005, email me your ideas"; }
I appreciate the help. The examples were great.
###