Index: src/wp-includes/functions.php
===================================================================
--- src/wp-includes/functions.php	(revision 47070)
+++ src/wp-includes/functions.php	(working copy)
@@ -286,7 +286,7 @@
 		}
 
 		$date = $datetime->format( $new_format );
-		$date = wp_maybe_decline_date( $date );
+		$date = wp_maybe_decline_date( $date, $format );
 	}
 
 	/**
@@ -312,13 +312,15 @@
  * formats (like 'j F Y'), the month name will be replaced with a correct form.
  *
  * @since 4.4.0
+ * @since 5.4.0 The `$format` parameter was added.
  *
  * @global WP_Locale $wp_locale WordPress date and time locale object.
  *
- * @param string $date Formatted date string.
+ * @param string $date   Formatted date string.
+ * @param string $format Optional. Date format to check. Default empty string.
  * @return string The date, declined if locale specifies it.
  */
-function wp_maybe_decline_date( $date ) {
+function wp_maybe_decline_date( $date, $format = '' ) {
 	global $wp_locale;
 
 	// i18n functions are not available in SHORTINIT mode
@@ -339,7 +341,14 @@
 		 * Match a format like 'j F Y' or 'j. F' (day of the month, followed by month name)
 		 * and decline the month.
 		 */
-		if ( preg_match( '#\b\d{1,2}\.? [^\d ]+\b#u', $date ) ) {
+		if ( $format ) {
+			$decline = preg_match( '#[dj]\.? F#', $format );
+		} else {
+			// If the format is not passed, try to guess it from the date string.
+			$decline = preg_match( '#\b\d{1,2}\.? [^\d ]+\b#u', $date );
+		}
+
+		if ( $decline ) {
 			foreach ( $months as $key => $month ) {
 				$months[ $key ] = '# ' . preg_quote( $month, '#' ) . '\b#u';
 			}
@@ -355,7 +364,14 @@
 		 * Match a format like 'F jS' or 'F j' (month name, followed by day with an optional ordinal suffix)
 		 * and change it to declined 'j F'.
 		 */
-		if ( preg_match( '#\b[^\d ]+ \d{1,2}(st|nd|rd|th)?\b#u', trim( $date ) ) ) {
+		if ( $format ) {
+			$decline = preg_match( '#F [dj]#', $format );
+		} else {
+			// If the format is not passed, try to guess it from the date string.
+			$decline = preg_match( '#\b[^\d ]+ \d{1,2}(st|nd|rd|th)?\b#u', trim( $date ) );
+		}
+
+		if ( $decline ) {
 			foreach ( $months as $key => $month ) {
 				$months[ $key ] = '#\b' . preg_quote( $month, '#' ) . ' (\d{1,2})(st|nd|rd|th)?\b#u';
 			}
Index: tests/phpunit/tests/functions/maybeDeclineDate.php
===================================================================
--- tests/phpunit/tests/functions/maybeDeclineDate.php	(revision 47070)
+++ tests/phpunit/tests/functions/maybeDeclineDate.php	(working copy)
@@ -41,7 +41,7 @@
 	 * @ticket 48606
 	 * @dataProvider data_wp_maybe_decline_date
 	 */
-	public function test_wp_maybe_decline_date( $test_locale, $input, $output ) {
+	public function test_wp_maybe_decline_date( $test_locale, $format, $input, $output ) {
 		global $locale, $wp_locale;
 
 		add_filter( 'gettext_with_context', array( $this, 'filter__enable_months_names_declension' ), 10, 3 );
@@ -52,7 +52,7 @@
 		$wp_locale->month          = $month_names['month'];
 		$wp_locale->month_genitive = $month_names['month_genitive'];
 
-		$declined_date = wp_maybe_decline_date( $input );
+		$declined_date = wp_maybe_decline_date( $input, $format );
 
 		remove_filter( 'gettext_with_context', array( $this, 'filter__enable_months_names_declension' ), 10 );
 
@@ -69,19 +69,20 @@
 
 	public function data_wp_maybe_decline_date() {
 		return array(
-			array( 'ru_RU', '21 Июнь', '21 июня' ),
-			array( 'ru_RU', '1 Январь 2016', '1 января 2016' ),
-			array( 'ru_RU', 'Январь 1st 2016', '1 января 2016' ),
-			array( 'ru_RU', 'Январь 1 2016', '1 января 2016' ),
-			array( 'ru_RU', 'Январь 1 16', '1 января 16' ),
-			array( 'ru_RU', 'Суббота, 19 Январь 2019 10:50', 'Суббота, 19 января 2019 10:50' ),
-			array( 'pl_PL', '1 Styczeń', '1 stycznia' ),
-			array( 'hr', '1. Siječanj', '1. siječnja' ),
-			array( 'ca', '1 de abril', "1 d'abril" ),
-			array( 'cs_CZ', '1. Červen', '1. června' ),
-			array( 'cs_CZ', '1. Červenec', '1. července' ),
-			array( 'it_IT', 'Lundeì 11 Novembre 2019', 'Lundeì 11 Novembre 2019' ),
-			array( 'el', 'Σάββατο, 19 Ιανουάριος 2019 10:50', 'Σάββατο, 19 Ιανουαρίου 2019 10:50' ),
+			array( 'ru_RU', 'j F', '21 Июнь', '21 июня' ),
+			array( 'ru_RU', 'j F Y', '1 Январь 2016', '1 января 2016' ),
+			array( 'ru_RU', 'F jS Y', 'Январь 1st 2016', '1 января 2016' ),
+			array( 'ru_RU', 'F j Y', 'Январь 1 2016', '1 января 2016' ),
+			array( 'ru_RU', 'F j y', 'Январь 1 16', '1 января 16' ),
+			array( 'ru_RU', 'F y', 'Январь 16', 'Январь 16' ),
+			array( 'ru_RU', 'l, d F Y H:i', 'Суббота, 19 Январь 2019 10:50', 'Суббота, 19 января 2019 10:50' ),
+			array( 'pl_PL', 'j F', '1 Styczeń', '1 stycznia' ),
+			array( 'hr', 'j. F', '1. Siječanj', '1. siječnja' ),
+			array( 'ca', 'j F', '1 de abril', "1 d'abril" ),
+			array( 'cs_CZ', 'j. F', '1. Červen', '1. června' ),
+			array( 'cs_CZ', 'j. F', '1. Červenec', '1. července' ),
+			array( 'it_IT', 'l j F Y', 'Lundeì 11 Novembre 2019', 'Lundeì 11 Novembre 2019' ),
+			array( 'el', 'l, d F Y H:i', 'Σάββατο, 19 Ιανουάριος 2019 10:50', 'Σάββατο, 19 Ιανουαρίου 2019 10:50' ),
 		);
 	}
 
