I’ve seen the following code promoted to calculate age from a DOB entry. But where does the code have to be installed, is it functions.php? And how would I save the output of this code to a ACF titled “age”? I don’t need it to appear on the screen – just saved backend, so can the echo below be deleted?
<?php
$date = get_field(‘date_of_birth’);
$birthday = new DateTime($date);
$interval = $birthday->diff(new DateTime);
echo $interval->y.’ years old’;
?>