首页 > 解决方案 > 在 ACF DateTimePicker 字段的 48 小时之前显示 DIV,并在相同 ACF DateTimePicker 字段的 24 小时之后隐藏

问题描述

我试图在指定的 ACF DateTimePicker 的 48 小时之前显示一个 ACF 字段,并希望在 24 小时后隐藏它,这些字段总是显示,并且在 24 小时后没有隐藏,你能帮我解决我做错了什么吗?下面是我的代码

    <?php //show match predictions only of it has a value and in between the specified date and time 
    $showPredictionTime = date("d/m/Y, g:i a", strtotime('+54 hours', time()));
     $hidepredictionTime = date("d/m/Y, g:i a", strtotime('+78 hours', time()));
    $matchStartTime = get_sub_field('match_time'); 
      if (get_sub_field('match_predictions_url') && $showPredictionTime >= $matchStartTime && $matchStartTime <= $hidepredictionTime ) { ?>
     <div class="elementor-button-wrapper"> 
<a href="<?php the_sub_field('match_predictions_url'); ?>" class="elementor-button-link elementor-button elementor-size-xs" role="button"> 
<span class="elementor-button-content-wrapper">
<span class="elementor-button-text">Predictions</span>
</span> 
    </a> 
    </div>
    <?php }  
    ?>

标签: phpwordpressadvanced-custom-fieldsdatetimepicker

解决方案


推荐阅读