Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the community forum?
All Topics
info420

Change Date Format in Export

Hello,
there is a way to set the date field in “l d/m/Y” format when export CSV??

1 month ago
Stefan
Developer

This is not possible to change on our settings page, but you can use the following hook to alter the export value for your columns.

ac/export/value

The first example explains how you can change the date format of a custom field column

1 month ago
info420

Hello,
thank you very much for your fast reply.

I have used Toolset for create my custom field. The toolset field name is wpcf-data.

I have tried to add the code but it’s not working.

Can you help me to solve it.

THX

1 month ago
info420

This is the code:

function aca_export_custom_field_date_format( $value, $column, $post_id ) {

// Check for the Custom Field Column
if ( $column instanceof AC\Column\CustomField ) {

if ( ‘date’ === $column->get_field_type() ) {

if ( $timestamp = ac_helper()->date->strtotime( $value ) ) {
$value = date( ‘l d/m/Y’, $timestamp );
}

};

}

return $value;
}

add_filter( ‘ac/export/value’, ‘aca_export_custom_field_date_format’, 10, 3 );

1 month ago
Stefan
Developer

Did you also use the Toolset integration and column?
In that case, you’ll need to change the snippet to work with the Toolset column instead of the Custom Field column and you probably want to check the column for a specific meta key.
The conditional will probably look something like:

if( $column instanceof ACA\Types\Column and $column->get_meta_key() === 'wpcf-data' )

1 month ago

You must be logged in to reply to this topic.