天天看點

php使用intl擷取農曆

$date = \IntlCalendar::createInstance(NULL, '[email protected]=chinese');// 使用農曆

$format = new \IntlDateFormatter('zh_CN', \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, null, $date, 'U年M月d日 HH:mm:ss');// 這裡的格式化要使用ICU的格式
// 參考:http://userguide.icu-project.org/formatparse/datetime

echo $format->format(strtotime('2017-12-01 16:11:04'));// 輸出:丁酉年10月14日 16:11:04

echo $format->format(time());// 輸出:己亥年12月12日 16:16:37
           

php5.4以後是自帶intl擴充的,但是需要開啟。