Support

Account

Home Forums General Issues Hide date field if empty Reply To: Hide date field if empty

  • I see the problem now, sorry, it was my fault, forgot to put the end of the if statement inside of php

    
    <?php 
    if (get_field('data_of_birth', false, false)) {
      // get raw date
      $date = get_field('date_of_birth', false, false);
      // make date object
      $date = new DateTime($date);
      echo $date->format('M j, Y'); ?> (<?php 
        $date = get_field('date_of_birth');
        $birthday = new DateTime($date);
        $interval = $birthday->diff(new DateTime);
        echo $interval->y.' years old';
      ?>)<?php 
    } // end if date
    ?>