1010use Magento \Framework \App \ObjectManager ;
1111use Magento \Framework \Json \EncoderInterface ;
1212use Magento \Framework \Locale \Bundle \DataBundle ;
13+ use Magento \Framework \Locale \Resolver ;
1314use Magento \Framework \Locale \ResolverInterface ;
1415
1516/**
@@ -171,6 +172,8 @@ protected function getFormFilter()
171172 /**
172173 * Apply output filter to value
173174 *
175+ * Normalizes date to display format with standard numerals to avoid localized numerals (e.g., Arabic)
176+ *
174177 * @param string $value
175178 * @return string
176179 */
@@ -181,7 +184,7 @@ protected function applyOutputFilter($value)
181184 $ value = date ('Y-m-d ' , $ this ->getTime ());
182185 $ value = $ filter ->outputFilter ($ value );
183186 }
184- return $ value ;
187+ return $ this -> normalizedDobOutput ( $ value) ;
185188 }
186189
187190 /**
@@ -462,4 +465,31 @@ private function setTwoMonthPlaces(string $format): string
462465 $ format
463466 );
464467 }
468+
469+ /**
470+ * Normalize the dob for a proper output on the frontend
471+ *
472+ * Converts localized date format (with potentially localized numerals like Arabic) to standard numerals
473+ *
474+ * @param mixed $value
475+ * @return mixed
476+ */
477+ private function normalizedDobOutput (mixed $ value ): mixed
478+ {
479+ if (empty ($ value )) {
480+ return $ value ;
481+ }
482+ $ locale = $ this ->localeResolver ->getLocale ();
483+ $ dateFormat = $ this ->getDateFormat ();
484+ $ dateTime = $ this ->_localeDate ->date ($ value , $ locale , false , false );
485+ $ formatter = new \IntlDateFormatter (
486+ Resolver::DEFAULT_LOCALE ,
487+ \IntlDateFormatter::NONE ,
488+ \IntlDateFormatter::NONE ,
489+ $ dateTime ->getTimezone (),
490+ null ,
491+ $ dateFormat
492+ );
493+ return $ formatter ->format ($ dateTime );
494+ }
465495}
0 commit comments