(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL intl >= 1.0.0)
IntlDateFormatter::getDateType -- datefmt_get_datetype — 取得 IntlDateFormatter 使用的日期類型
物件導向風格
程序式風格
傳回格式器所使用的日期類型。
formatter
格式器資源。
範例 #1 datefmt_get_datetype() 範例
<?php
$fmt = datefmt_create(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo '格式器的日期類型為:' . datefmt_get_datetype($fmt);
echo '第一個格式化輸出的日期類型為 ' . datefmt_format($fmt, 0);
$fmt = datefmt_create(
'en_US',
IntlDateFormatter::SHORT,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo '現在格式器的日期類型為:' . datefmt_get_datetype($fmt);
echo '第二個格式化輸出的日期類型為 ' . datefmt_format($fmt, 0);
?>
範例 #2 物件導向範例
<?php
$fmt = new IntlDateFormatter(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo '格式器的日期類型為:' . $fmt->getDateType();
echo '第一個格式化輸出為 ' . $fmt->format(0);
$fmt = new IntlDateFormatter(
'en_US',
IntlDateFormatter::SHORT,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo '現在格式器的日期類型為:' . $fmt->getDateType();
echo '第二個格式化輸出為 ' . $fmt->format(0);
?>
上述範例將輸出
datetype of the formatter is : 0 First Formatted output is Wednesday, December 31, 1969 4:00:00 PM PT Now datetype of the formatter is : 2 Second Formatted output is 12/31/69 4:00:00 PM PT