首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Php在设定日期后显示信息

Php在设定日期后显示信息
EN

Stack Overflow用户
提问于 2018-07-28 02:27:06
回答 1查看 101关注 0票数 0

嗨,谢谢你抽出时间来看我的问题。我目前有一个Php脚本,它允许我隐藏设置日期后的内容,并将其替换为默认文本,您可以在下面看到它:

代码语言:javascript
复制
      <?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 } ?>

我现在尝试做的是添加一个额外的脚本,在设定的日期打开它,所以基本上它的功能是双向的,在设定的日期后隐藏内容,然后在另一个日期到来时激活内容,我一直很难弄清楚,如果你能帮我一把,我会很高兴!

非常感谢您的时间和帮助。

EN

回答 1

Stack Overflow用户

发布于 2018-07-28 02:50:21

已更新答案。

根据你的问题和评论中的场景,从今天起5天后,你的$first_expire_date的报价第一次到期。如果您想在10天后再次开始第二次优惠,并在第二次优惠开始日期后15天内继续执行此优惠,您应尝试使用,

代码语言:javascript
复制
<?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 } ?>

我希望它能帮上忙。

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51563599

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档