Let's say you want to show a text field (announcement
) based on the time (a scheduled notification message for instance).
You need two date-time fields. In our example, one is called start_date
and the other end_date
.
<?php
$DateNow = date('Y-m-d H:i:s');
$DateStart = get_field('start_date', false, false);
$DateEnd = get_field('end_date', false, false);
if($DateNow > $DateStart && $DateNow < $DateEnd) {
echo the_field('announcement');
}
?>