RE: [PHP] Display after a certain date
| From: | Jay Blanchard | Date: | Fri, 05 Sep 2003 11:44:10 +0000 |
| Subject: | RE: [PHP] Display after a certain date | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-161743@lists.php.net to get a copy of this message | ||
[snip]
Anyone have a quick fix for a part of an html page that I do not want to
display until after October 1st, and not after October 31st ?
[/snip]
You must have missed the conditionals part of the manual....
<?php // untested
$display_start = "2003-10-01";
$display_end = "2003-10-31";
if((date("Y-m-d") >= $display_start) && (date("Y-m-d") <=
$display_end)){
print($stuff);
}
?>
Now, if you are getting the stuff out of the database you can select
according to date if you have start and end dates as columns (as would
be in most CMS databases);
SELECT paragraph
FROM tblArticles
WHERE CURRENT_DATE() BETWEEN '2003-10-01' AND '2003-10-31'
HTH and Have a pleasant day.