Home › Forums › ACF PRO › Change date format with jquery › Reply To: Change date format with jquery
That is most likely because ACF4 let’s you set the storage format and the other plugin uses whatever is stored in the field. ACF5 does not have this option and stores the dates in a standard way that allows sorting by date field. You can only sort by dates it the order is year/month/day.
You should talk the the developers of the other plugin and ask them is there is a way to filter the values of custom fields before they are displayed.
Your other choice would be to create a separate field that holds the value that you want displayed.
add_filter('acf/update_value/name=the_acf_date_field_name', 'store_date_field_in_displayable_format', 10, 3);
function store_date_field_in_displayable_format($value, $post_id, $field) {
if ($value) {
$new_value = date('jS F Y', strtotime($value));
update_post_meta($post_id, 'field_name_to_use_in_other_plugin', $new_value);
}
return $value;
}
field_name_to_use_in_other_plugin
needs to be a unique field name and then you use that field name to set up the other plugin. Personally, I’d go with the first option, but I can’t really help you figure out how to use that other plugin since I’ve never used it.
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’re reaching out to our multilingual users to ask for help in translating ACF 6.1. Help make sure the latest features are available in your language here: https://t.co/TkEc2Exd6U
— Advanced Custom Fields (@wp_acf) May 22, 2023
© 2023 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.