MrBlackDrag0nfly MrBlackDrag0nfly - 2 months ago 7
PHP Question

Echoing something out on a specific date every year

So I'm trying to make a message appear on one specific date of the year.

My code now:

<?php
$year = date("Y");

if(checkdate(5, 22, $year) === TRUE) {
echo '<b>something</b>';
}else {
echo '';
}

?>


But the message appears howsoever, no matter the date.

Hope you can help me,

Thanks in advance!

Answer

If you don't have to use checkdate, this is an alternative.

<?php
if (date('Y-m-d') == date('Y').'-05-22') {
    echo '<b>something</b>';
}    else {
    echo '';
}
?>
Comments