I have a custom post type with a custom field that takes a date. The posts are later ordered by the date in that custom field. Unfortuately I formatted the date incorrectly and there are already a number of posts with the post meta value as dd-mm-yyyy. I have found that to use this value as orderby (WPQuery) it needs to be yyyy-mm-dd. So I was going to try:
$args = array(
'posts_per_page' => -1,
'post_type'=> 'match_report'
);
$wp_query = new WP_Query();
$wp_query->query($args);
if ( $wp_query->have_posts() ) :
while ( $wp_query->have_posts() ) : $wp_query->the_post();
$matchdate = get_post_meta($post->ID, 'report_date', true);
$new_matchdate = strftime("%Y-%m-%d", $matchdate);
update_post_meta($post->ID, 'report_date', $new_matchdate);
endwhile;
wp_reset_postdata();
endif; ?>
but I am getting
Notice: A non well formed numeric value encountered in...
and when I echo $new_matchdate
I get 1970-01_01 so obviously I am doing this incorrectly. Any help would be appreciated.