# 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.

- Type: PHP
- Runs: Run everywhere
- Category: [Multilingual](https://wpide.com/library/category/multilingual/)
- Tags: date-format, locale, time-format
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/i18n-date-format-per-locale/

## Code

```php
$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 use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Date and Time Formats Per Language" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
