As per the code reference the_time
filter recieves two parameters – $get_the_time
and $format
. You can use the latter to determine which formatting option to use.
add_filter( 'the_time', 'changer_date_format', 10, 2 );
function changer_date_format( $ladate, $format ) {
global $post;
if ( 'd M' === $format ) {
return get_post_time( get_option( 'date_format' ), false, $post, true );
} else if ( 'H:i' === $format ) {
return get_post_time( get_option( 'time_format' ), false, $post, true );
} else {
return $ladate;
}
}