Date Time Picker

Other topics

Ouput date-time value

Display the date by itself (custom field is tour_date):

<p>Tour Date <?php the_field('tour_date');?></p>

Use two date-time fields to show a field

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');
}    
?>

Contributors

Topic Id: 8354

Example Ids: 26776,26777

This site is not affiliated with any of the contributors.