Date and Time Formats Per Language
Uses a different date and time format for each language, such as 27 October 2026 in British English and 27. Oktober 2026 in German, whenever the site or user language changes.
Opens WPIDE on
Code
$wpide_formats = array( // Locale => array( date format, time format ).
'en_GB' => array( 'j F Y', 'H:i' ),
'de_DE' => array( 'j. F Y', 'H:i' ),
'fr_FR' => array( 'j F Y', 'H\hi' ),
'ja' => array( 'Y年n月j日', 'H:i' ),
);
add_filter( 'option_date_format', function ( $format ) use ( $wpide_formats ) {
$locale = determine_locale();
return isset( $wpide_formats[ $locale ] ) ? $wpide_formats[ $locale ][0] : $format;
} );
add_filter( 'option_time_format', function ( $format ) use ( $wpide_formats ) {
$locale = determine_locale();
return isset( $wpide_formats[ $locale ] ) ? $wpide_formats[ $locale ][1] : $format;
} );
Notes
Add locales to $wpide_formats; languages not listed fall back to the formats in Settings > General. Works with any plugin that switches the locale.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.