嗨,谢谢你抽出时间来看我的问题。我目前有一个Php脚本,它允许我隐藏设置日期后的内容,并将其替换为默认文本,您可以在下面看到它:
<?php if (date('Y-m-d') <= '2018-05-30') { ?>
<li><p><strong>Apply to Graduate:</strong></p>
<p><a href="app-graduate-form.php" class="applyBtn">Apply to Graduate</a></p>
</li>
<?php } else { ?>
<p><li><strong>The application to graduate is not available at this time.</strong> If you qualify to graduate, the Registrar’s Office will notify you when the application to graduate is available.</li></p>
<?php } ?>
我现在尝试做的是添加一个额外的脚本,在设定的日期打开它,所以基本上它的功能是双向的,在设定的日期后隐藏内容,然后在另一个日期到来时激活内容,我一直很难弄清楚,如果你能帮我一把,我会很高兴!
非常感谢您的时间和帮助。
发布于 2018-07-28 02:50:21
已更新答案。
根据你的问题和评论中的场景,从今天起5天后,你的$first_expire_date
的报价第一次到期。如果您想在10天后再次开始第二次优惠,并在第二次优惠开始日期后15天内继续执行此优惠,您应尝试使用,
<?php
// Today
$currentdate = date('Y-m-d');
// Offer starts. Set it as you want. You can set it to '2018-05-30' in that case you already get $first_expire_date expires.
$offer_start_date = '2018-07-28';
// You can add +220 days, or +1 month or +2 years in the following snippet as you prefer
// You can also subtract -3 months or -11 years or -1 day as you need
$first_expire_date = date('Y-m-d',strtotime('+5 days',strtotime($offer_start_date )));
//2nd time offer start date
$second_valid_date_start = date('Y-m-d',strtotime('+5 days',strtotime($first_expire_date)));
//2nd time offer end date
$second_valid_date_end = date('Y-m-d',strtotime('+15 days',strtotime($second_valid_date_start)));
?>
<?php if ($currentdate <= $first_expire_date) { ?>
<li><p><strong>Apply to Graduate:</strong></p>
<p><a href="app-graduate-form.php" class="applyBtn">Apply to Graduate</a></p>
</li>
<?php }else ?>
<?php if (isset($second_valid_date_start) && ($second_valid_date_start <= $second_valid_date_end)) { ?>
<li><p><strong>Apply to Graduate:</strong></p>
<p><a href="app-graduate-form.php" class="applyBtn">Apply to Graduate</a></p>
</li>
<?php }else{ ?>
<p><li><strong>The application to graduate is not available at this time.</strong> If you qualify to graduate, the Registrar’s Office will notify you when the application to graduate is available.</li></p>
<?php } ?>
我希望它能帮上忙。
https://stackoverflow.com/questions/51563599
复制相似问题