Home › Forums › General Issues › Passing all ACF form data to a React table › Reply To: Passing all ACF form data to a React table
If a value has not been set then ACF will return NULL for the value and I don’t know what effect passing null to new DateTime()
has. I’ve personally never used this class for dates, but that NULL value is probably what’s causing the wrong date value.
something like this would do the same thing and I would not consider it hack. It’s the way that ACF works.
$formatted_date = '';
if (get_field('date_completed', $post_id) {
$date = get_field('date_completed', $post_id);
$date_completed = new DateTime($date);
$formatted_date = $date_completed->format('M j Y');
}
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.