Last active
August 29, 2015 14:02
-
-
Save jameswilson/d5cf9c14b9d112017c65 to your computer and use it in GitHub Desktop.
Multi-language date formats for Drupal 7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Place this in a custom module, eg "mymodule.module" | |
/** | |
* Implements hook_date_format_types(). | |
*/ | |
function mymodule_date_format_types() { | |
return array( | |
'post_date' => t('Post date'), | |
); | |
} | |
/** | |
* Implements hook_date_formats(). | |
*/ | |
function mymodule_date_formats() { | |
$formats = array(); | |
// The following formats will be available for localizing the "Post date" | |
// date format into various language formats. | |
$formats[] = array( | |
'type' => 'post_date', | |
'format' => 'j F Y', // Day Month Year (default) | |
'locales' => array(), | |
); | |
$formats[] = array( | |
'type' => 'post_date', | |
'format' => 'j. F Y', // Day. Month Year (Norwegian, Danish) | |
'locales' => array(), | |
); | |
$formats[] = array( | |
'type' => 'post_date', | |
'format' => 'j/ F Y', // Day/ Month Year (German) | |
'locales' => array(), | |
); | |
$formats[] = array( | |
'type' => 'post_date', | |
'format' => 'j \d\e F \d\e Y', // Day de Month de Year (Spanish, Portuguese) | |
'locales' => array(), | |
); | |
$formats[] = array( | |
'type' => 'post_date', | |
'format' => 'j F Y \r.', // Day Month Year r. (Polish, Russian) | |
'locales' => array(), | |
); | |
$formats[] = array( | |
'type' => 'post_date', | |
'format' => 'F j, Y', // Month Day, Year (US) | |
'locales' => array(), | |
); | |
$formats[] = array( | |
'type' => 'post_date', | |
'format' => 'n.j.Y', // Month.Day.Year (Finnish) | |
'locales' => array(), | |
); | |
$formats[] = array( | |
'type' => 'post_date', | |
'format' => 'Y F j', // Year Month Day (APAC) | |
'locales' => array(), | |
); | |
$formats[] = array( | |
'type' => 'post_date', | |
'format' => 'Y. F j.', // Year. Month Day. (Hungarian) | |
'locales' => array(), | |
); | |
$formats[] = array( | |
'type' => 'post_date', | |
'format' => 'Y \年 n \月 j \日', // Y M D (Chinese/Taiwan) | |
'locales' => array(), | |
); | |
$formats[] = array( | |
'type' => 'post_date', | |
'format' => 'Y\年 n\月 j\日', // Y M D (Japanese) | |
'locales' => array(), | |
); | |
$formats[] = array( | |
'type' => 'post_date', | |
'format' => 'Y\년 n\월 j\일', // Y M D (Korean) | |
'locales' => array(), | |
); | |
return $formats; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment