Format Date

Change the date format of the “Date of Donation” column in the Donations export.

<?php
/**
 * Format the date for a custom post type's meta field.
 *
 * @param  mixed  $value The value to set.
 * @param  string $key   The key to set.
 * @param  array  $data  The set of data.
 * @return mixed
 */
function my_custom_format_date( $value, $key, $data ) {
    // Check if this is the date field you want to format
    if ( 'custom_date_key' == $key ) {
        // Change 'custom_date_key' to your actual meta key
        // Change 'd/m/Y' to your preferred format
        $value = date( 'd/m/Y', strtotime( $value ) );
    }

    return $value;
}
add_filter( 'your_custom_filter_hook', 'my_custom_format_date', 20, 3 );

Post Comment