Support

Account

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

  • 
    <?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';
      ?>)
    } // end if date