Created
February 24, 2012 09:09
-
-
Save fetus-hina/1899670 to your computer and use it in GitHub Desktop.
Zend_Date (と Zend_Locale) を使ってそれなりに地域化されたフォーマットをするサンプル
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 | |
require_once('Zend/Date.php'); | |
$locales = array('ja_JP', 'en_US', 'en_GB'); | |
$formats = | |
array( | |
'DATE_FULL' => Zend_Date::DATE_FULL, | |
'DATE_LONG' => Zend_Date::DATE_LONG, | |
'DATE_MEDIUM' => Zend_Date::DATE_MEDIUM, | |
'DATE_SHORT' => Zend_Date::DATE_SHORT); | |
$time = time(); | |
$date = Zend_Date::now(); | |
foreach($locales as $locale) { | |
echo "*** {$locale} ***\n"; | |
foreach($formats as $format_disp => $format) { | |
echo $format_disp . ": \n"; | |
echo ' ' . $date->toString($format, null, $locale) . "\n"; | |
} | |
echo "\n"; | |
} |
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
*** ja_JP *** | |
DATE_FULL: | |
2012年2月24日金曜日 | |
DATE_LONG: | |
2012年2月24日 | |
DATE_MEDIUM: | |
2012/02/24 | |
DATE_SHORT: | |
12/02/24 | |
*** en_US *** | |
DATE_FULL: | |
Friday, February 24, 2012 | |
DATE_LONG: | |
February 24, 2012 | |
DATE_MEDIUM: | |
Feb 24, 2012 | |
DATE_SHORT: | |
2/24/12 | |
*** en_GB *** | |
DATE_FULL: | |
Friday, 24 February 2012 | |
DATE_LONG: | |
24 February 2012 | |
DATE_MEDIUM: | |
24 Feb 2012 | |
DATE_SHORT: | |
24/02/2012 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment