FacetWP – convert MM/DD/YYYY date to YYYY-MM-DD

mgibbs189

{{gist file=”functions.php” lang=”php”}}
<?php
function fwp_format_date( $params, $class ) {
if ( ‘facet_age’ == $params[‘facet_name’] ) {
$date = explode( ‘/’, $params[‘facet_value’] );
$date = $date[2] . ‘-‘ . $date[0] . ‘-‘ . $date[1];
$params[‘facet_value’] = $date;
$params[‘facet_display_value’] = $date;
}
return $params;
}
add_filter( ‘facetwp_index_row’, ‘fwp_format_date’, 10, 2 );
{{/gist}}