I'm trying to do a simple if echo statement.
<?php if (time("mm-dd") > strtotime("11-01") && time("mm-dd") < strtotime("02-28"))echo 'stuff' ?>
Basically I want to echo something if today is either Nov, Dec, Jan, Feb. The code works if I use time()
and the full year but I'd like to just compare the month, day. I think I have some silly syntax error that I just can't figure out. This code snippet is placed in the <head>
of my html if that makes a difference. Little help. Thanks.
This is what I ended up with. Thanks!
<?php if ($today > '12-16' || $today < '01-08') echo 'yes' ?>
with $today = date("m-d")
date
function instead of time.&&
to||
. Nom-d
date string will ever be both greater than11-01
and less than02-28
.date()
twice, why not assign the result to a variable?Here it is all together: