我需要帮助,以显示一个简单的信息,当我的一个研讨会结束。我的想法是“这个研讨会已经结束了”,但我想不出正确的格式。我在自定义字段中使用wordpress和高级自定义域插件:
代码:
<?php
$today = date('Ymd');
$sem_date = get_field('sem_date'); // Output format d / m / y (has to be this format on the site)
if($today > $sem_date){ ?>
<div class="oops">
This seminar has ended!
</div>
<?php } ?>发布于 2015-11-13 02:43:59
获取今天的日期作为日期对象:
$today = new DateTime( 'today', new DateTimeZone('America/Chicago') );获取研讨会日期作为日期对象:
$sem_date = new DateTime( get_field('sem_date') );现在您可以比较这两个日期对象:
$today > $sem_datehttps://stackoverflow.com/questions/33684293
复制相似问题