Home › Forums › General Issues › Echo date picker field returns fatal error › Reply To: Echo date picker field returns fatal error
Well I finally solved it by changing the store format to yymmdd. After that I could use the code example from the documentation like this.
$date = DateTime::createFromFormat('Ymd', get_field('date_picker'));
echo $date->format('d-m-Y');
I changed the output value to j F Y
but then found out that the output was English even though it was displayed in Dutch in the WP admin area. But well that was easily sorted with the translation snipper from the documentation.
<?php
$dateformatstring = "l d F, Y";
$unixtimestamp = strtotime(get_field('date_picker'));
echo date_i18n($dateformatstring, $unixtimestamp);
?>
So in the end I didn’t even have to use my code that was causing the error and was making it too complicated for myself when I could use the code examples. But well, I learned something again as this was my first usage of the date picker field.
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!
Our guide looks into WordPress custom fields and how they stack up against the possibilities of ACF.
— Advanced Custom Fields (@wp_acf) July 18, 2022
https://t.co/hk3yibkHyk
© 2022 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.