Using render_block filter to modify core/post-date block

I wanted to play with the styling of the core/post-date block on this site, and needed to wrap the month, day and year in <span>.

Here is how I used render_block to accomplish this:

add_filter( 'render_block', 'render_block_post_date', 10, 2 );
 * Filter the output of the Post Date block
 * @param string $block_content The block content about to be appended.
 * @param array $block The full block, including name and attributes.
 * @return void
function render_block_post_date( $block_content, $block ) {
	if (
		$block['blockName'] === 'core/post-date' &&
		! is_admin() &&
		! wp_is_json_request()
	) {
		global $post;
		$month = get_the_date( 'M', $post->ID );
		$day   = get_the_date( 'd', $post->ID );
		$year  = get_the_date( 'Y', $post->ID );

		return sprintf(
			'<div class="wp-block-post-date"><time datetime="%1$s"><span class="wp-block-post-date__month">%2$s</span><span class="wp-block-post-date__day">%3$s</span><span class="wp-block-post-date__year">%4$s</span></time></div>',
			get_the_date( 'c', $post_ID ),

	return $block_content;

Just drop that in your theme’s functions.php or where ever you prefer to keep these modifications, and you’ll be on your way.