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
?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.