I’m saving values to the meta table outside of ACF into a field handled by the ACF date component.
When values are saved in the meta table with the format yy-mm-dd ACF is unable to display them in the admin, despite the date format being set to this in the admin.
Any way around this? I need the format to stay as yy-mm-dd in the meta table as its expected in this format by the front end code.
We’ve got a pro license if that helps 🙂
No ACF saves the date -format in Ymd since that’s the most versatile dateformat to work with. However this shouldn’t be a problem since you can easily retrieve it on the front end where you need it and reformat it to yy-mm-dd (or Y-m-d as it would be with PHP).
So if I where you I’d make sure that when you save the meta value outside of ACF to save it as Ymd like this:
$Ymd = date('Ymd', strtotime($mydatestring));
and to display it in whatever format you want on the front end you do a very similar:
echo date( 'Y-m-d', strtotime( get_field('my_date_field') ) );