php show a content in a given period of the year

You can use a very simple php code, f.e. for Christmas and Happy New Year greetings:

<?php 
$dataattuale = date('m-d');
$inizioauguri = date('m-d', strtotime("11/13"));
$finauguri = date('m-d', strtotime("01/10"));  
if (($dataattuale >= $inizioauguri) && ($finauguri <= $finauguri))
{include "$root/natalizio.php";} 
?>

The above code show the content of natalizio.php (in root folder) from November 13th to January 10th.

Another example

$now = date('Y-m-d');
$end = date('2024-07-15');  
if ($now <= $end)
{echo "some text";}

Lascia un commento

Il tuo indirizzo email non sarĂ  pubblicato. I campi obbligatori sono contrassegnati *