note 105460 modified in intldateformatter.create by danbrown
| From: | danbrown@php.net | Date: | Sat, 20 Aug 2011 15:59:21 +0000 |
| Subject: | note 105460 modified in intldateformatter.create by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-182603@lists.php.net to get a copy of this message | ||
It should be noted that the locale string passed into IntlDateFormatter's constructor supports
UCA keywords. So you can, for example, do things like this to output the year as a Japanese era
year:
<?php
$now = new DateTime(); //DateTime is a core PHP class as of version 5.2.0
$formatter = new IntlDateFormatter('ja_JP', IntlDateFormatter::FULL,
IntlDateFormatter::FULL, 'Asia/Tokyo', IntlDateFormatter::GREGORIAN);
echo 'It is now: "' . $formatter->format($now) . '" in Tokyo' .
"\n";
//above gives [It is now: "2011å¹´8æ19æ¥éææ¥
23æ32å27ç§JST" in Tokyo]
$formatter = new IntlDateFormatter('ja_JP@calendar=japanese', IntlDateFormatter::FULL,
IntlDateFormatter::FULL, 'Asia/Tokyo', IntlDateFormatter::TRADITIONAL);
echo 'It is now: "' . $formatter->format($now) . '" in Tokyo' .
"\n";
//above gives [It is now: "å¹³æ23å¹´8æ19æ¥éææ¥
23æ32å27ç§JST" in Tokyo]
?>
--was--
It should be noted that the locale string passed into IntlDateFormatter's constructor supports
UCA keywords. So you can, for example, do things like this to output the year as a Japanese era
year:
$now = new DateTime(); //DateTime is a core PHP class as of version 5.2.0
$formatter = new IntlDateFormatter('ja_JP', IntlDateFormatter::FULL,
IntlDateFormatter::FULL, 'Asia/Tokyo', IntlDateFormatter::GREGORIAN);
echo 'It is now: "' . $formatter->format($now) . '" in Tokyo' .
"\n";
//above gives [It is now: "2011å¹´8æ19æ¥éææ¥
23æ32å27ç§JST" in Tokyo]
$formatter = new IntlDateFormatter('ja_JP@calendar=japanese', IntlDateFormatter::FULL,
IntlDateFormatter::FULL, 'Asia/Tokyo', IntlDateFormatter::TRADITIONAL);
echo 'It is now: "' . $formatter->format($now) . '" in Tokyo' .
"\n";
//above gives [It is now: "å¹³æ23å¹´8æ19æ¥éææ¥
23æ32å27ç§JST" in Tokyo]
http://php.net/manual/en/intldateformatter.create.php