【发布时间】:2016-12-17 16:50:53
【问题描述】:
我正在尝试做一个简单的 if echo 语句。
<?php if (time("mm-dd") > strtotime("11-01") && time("mm-dd") < strtotime("02-28"))echo 'stuff' ?>
基本上,如果今天是 11 月、12 月、1 月、2 月,我想回显一些内容。如果我使用 time() 和全年,则代码有效,但我只想比较月、日。我想我有一些我无法弄清楚的愚蠢的语法错误。这段代码 sn-p 放在我的 html 的 <head> 中,如果这有区别的话。帮助不大。谢谢。
这就是我最终的结果。谢谢!
<?php if ($today > '12-16' || $today < '01-08') echo 'yes' ?>
$today = date("m-d")
【问题讨论】:
-
请don't edit your question and add the solution there。相反,accept an existing answer 或 add your own answer,然后接受它。这样,问题将被标记为已解决,其他用户将来可能会从中受益。
标签: php date compare strtotime