Home › Forums › Backend Issues (wp-admin) › update Datepicker-Field issue › Reply To: update Datepicker-Field issue
@phoenix-systems I have kind of the same problem and I think I found the problem, and the solution.
I realized that updating a DatePicker field, requires you to pass the date with the ‘Ymd’ format (PHP) no matter what format you are using (they really should add it to the documentation).
my code: (dob = date of birth…)
$dob_str = '23/11/1984';
$date = DateTime::createFromFormat('d/m/Y', $dob_str);
$date = $date->format('Ymd');
update_field('date_of_birth', $date, $post_id);
Also worth mentioning is that if you are trying to update a field with the same value (from the database) the function returns false
, but that’s WP behaviour if I’m not mistaken.
Hope it helps you.
Daniel
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.