Conor Treacy

Change Date Format for Elementor Date Picker

Elementor Date Picker always returns the date as YYYY/MM/DD and does not adhere to the format request in the WordPress Settings.

If you add the following code to your functions.php file, it will change the format in the contact form field to use “d/m/Y”.

// Custom Date Format for Date Picker in Elementor
function custom_date_format_script() {
    ?>
    <script type = "text/javascript" >
    jQuery(document).ready(function ($) {
        setTimeout(function () {
            $('.elementor-date-field.flatpickr-input').each(function () {
                if (typeof flatpickr !== 'undefined') {
                    flatpickr($(this)[0], {dateFormat: 'd/m/Y'});
                }
            });
        }, 1000);
    });
    </script>
    <?php 
} 
add_action('wp_footer', 'custom_date_format_script');

The code above will affect all pages; however, if you only need to affect certain pages, you can isolate them in the code too. This will help for faster speeds on the site and only execute on the pages where the code is needed.