我想找出一个特定的一年的中国新年日期使用PHP。2022年,我预计2022年2月1日。
发布于 2022-06-16 08:25:58
使用IntlDateFormatter很容易做到这一点。
$year = 2022;
$formatter = new IntlDateFormatter(
'zh-CN@calendar=chinese',
IntlDateFormatter::SHORT,
IntlDateFormatter::NONE,
'Europe/Berlin',
IntlDateFormatter::TRADITIONAL
);
$timeStamp = $formatter->parse($year.'/01/01');
$dateTime = date_create()->setTimeStamp($timeStamp);
echo $dateTime->format('j F Y'); //1 February 2022你自己用3v4l.org试试吧。
https://stackoverflow.com/questions/72642695
复制相似问题