• Resolved pipoulito

    (@pipoulito)


    Hello,

    When i export my ACF date (repeater) they display like this :
    20190418
    whereas in ACF they are set like this : 18/04/2019

    thanks for help

    • This topic was modified 7 years, 2 months ago by pipoulito.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author WP All Import

    (@wpallimport)

    Hi @pipoulito

    This is expected behavior because “20190418” is how ACF stores the date in the database. You can change the format using a custom PHP function on the field: http://www.wpallimport.com/tour/export-developer-friendly/. Example function:

    function my_change_date_format( $date ) {
    	if ( $obj = DateTime::createFromFormat( 'Ymd', $date ) ) {
    		return $obj->format( 'd/m/Y' );	
    	} else {
    		return null;
        }
    }

    See: https://d.pr/i/pSL9aK

    Thread Starter pipoulito

    (@pipoulito)

    thanks a lot !
    But as my datefield is in a repeater field , will it work ?

    • This reply was modified 7 years, 2 months ago by pipoulito.
    Plugin Author WP All Import

    (@wpallimport)

    Hi @pipoulito

    But as my datefield is in a repeater field , will it work ?

    In that case you’d need to write some custom code that uses the ‘wp_all_export_csv_rows’ hook: https://github.com/soflyy/wp-all-import-action-reference/blob/master/all-export/wp_all_export_csv_rows.php. Example snippet:

    function wp_all_export_csv_rows( $articles, $options, $export_id ) {
        foreach ($articles as $key => $article) {
            if ( ! empty( $article["A Repeating Group_date"] ) ) {
                $dates = explode( ",", $article["A Repeating Group_date"] );
                foreach ( $dates as $ikey => $ivalue ) {
                    $dates[ $ikey ] = my_change_date_format( $ivalue );
                }
                $articles[ $key ]["A Repeating Group_date"] = implode( ",", $dates );
            }
        }
        return $articles; // Return the array of records to export
    }
    add_filter( 'wp_all_export_csv_rows', 'wp_all_export_csv_rows', 10, 3 );
    
    function my_change_date_format( $date ) {
        if ( $obj = DateTime::createFromFormat( 'Ymd', $date ) ) {
            return $obj->format( 'd/m/Y' );	
        } else {
            return null;
        }
    }
    Thread Starter pipoulito

    (@pipoulito)

    thanks

    muy date are names : program_0_date, program_1_date …
    So how should i replace “A Repeating Group_date” please ?
    thanks

    • This reply was modified 7 years, 2 months ago by pipoulito.
    Plugin Author WP All Import

    (@wpallimport)

    Hey @pipoulito

    When possible we’re happy to provide examples to point you in the right direction, but unfortunately we can’t write/adjust/troubleshoot custom code for your project as part of our support.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘ACF date format’ is closed to new replies.