a
dd_filter( 'forminator_custom_form_mail_admin_message', 'wpmudev_show_formatted_date', 10, 5 );
function wpmudev_show_formatted_date( $message, $custom_form, $data, $entry, $cls ) {
if ( $custom_form->id == 3344 ) { //Please change the form ID here
preg_match_all('/\d{2}\/\d{2}\/\d{4}/', $message, $matches);
foreach ( $matches as $date ) {
if ( ! empty( $date ) ) {
foreach ( $date as $key => $val ) {
$date_formats = array( 'd/m/Y', 'Y-m-d', 'm-d-Y', 'd.m.Y' ); // Add more date formats if necessary
$date_obj = null;
foreach ( $date_formats as $format ) {
$date_obj = DateTime::createFromFormat( $format, $val );
if ( $date_obj ) {
break;
}
}
if ( $date_obj ) {
$timestamp = $date_obj->getTimestamp();
$locale = get_locale(); // Get the WordPress locale
setlocale( LC_TIME, $locale ); // Set the locale to the WordPress locale
$global_date = strftime( '%d/%B/%Y', $timestamp );
$message = str_replace( $val, $global_date, $message ) ;
}
}
}
}
}
return $message;
}
with some help of GPT I got a code that works with several input formats and will give you the desired one. I would be nice to have all the available formats for the confirmation emails, so in case you are using a confirmation languages you can adapt to your needs.
This will work for me for now. Thanks !