ACF change date field output

Forums › Forums › Search & Filter Pro › ACF change date field output

Tagged: 

Viewing 9 posts – 1 through 9 (of 9 total)
  • Anonymous
    #193028

    Hi,

    I want to filter some posts using the ACF date field. The output on the frontend looks like 20181224 (Ymd) and I would like to change it to 24 december 2018 (j F Y).

    Is this possible? If so, how do I do this?

    Thanks

    Trevor
    #193032

    In the Field Group Settings for the date field, what did you set on the formats?

    Where in the front end is this happening? In the post output?

    Anonymous
    #193038

    Hi Trevor,

    I have set the display format to : d/m/Y and the output to custom j F Y. I have already tried to change these settings but it’s still not working.

    It is happening in the filter. I use a dropdown and the options are in Ymd 20181224 and 20181225.

    Any idea?

    Thanks
    Britt

    Trevor
    #193042
    This reply has been marked as private.
    Anonymous
    #193151
    This reply has been marked as private.
    Trevor
    #193156

    Ah, I see now. You are not using the date/datepicker option, instead the choice option. You will need to make a bit of Custom coding to change the shown date using our Filter Input Object filter and process the ACF date into a Date format that you want.

    This should be an option I think, for the future. Is it OK for me to raise this as a feature request?

    Anonymous
    #193161

    Hi Trevor,

    We have it working now.

    It would be a nice feature for in the future. So you can request it.

    Thanks

    Anonymous
    #193165

    Hi Trevor,

    This is the code we’ve used btw. Maybe it’s useful 🙂

    function filter_function_name($input_object, $sfid)
        {
            if($input_object['name']=='_sfm_kalender_datum')
            {
                foreach($input_object['options'] as $option) {
                    if($option->value != "") {
                        $date = strtotime( $option->label );
                        $option->label = date('d m Y', $date);
                    }
                }
            }
            
            return $input_object;
        }
        add_filter('sf_input_object_pre', 'filter_function_name', 10, 2);
    Trevor
    #193167

    Thanks for sharing. I will tag this thread right now.

Viewing 9 posts – 1 through 9 (of 9 total)
Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.