我开发这个代码,查看德黑兰的时间和日期的PHP:级“应用程序 HTTP 控制器 IntlDateFormatter”未找到
$fmt = new IntlDateFormatter("[email protected]=persian", IntlDateFormatter::FULL,
IntlDateFormatter::FULL, 'Asia/Tehran', IntlDateFormatter::TRADITIONAL);
echo "Date: " . $fmt->format(time()) . "\n";
此代码工作正常,但是,我想在一个函数中使用它我在Laravel的控制器。
路线:
Route::get('/date', [
'as' => 'date', 'uses' => '[email protected]'
]);
控制器:
public function date() {
$fmt = new IntlDateFormatter("[email protected]=persian", IntlDateFormatter::FULL,
IntlDateFormatter::FULL, 'Asia/Tehran', IntlDateFormatter::TRADITIONAL);
echo "Date: " . $fmt->format(time()) . "\n";
}
,其结果是:
类 '应用\ HTTP \控制器\ IntlDateFormatter' 未找到
我知道Laravel中没有IntlDateFormatter类,但我除了在这里使用php类外。我的错误是什么?
添加更多的代码和说明请 –
尝试使用'\ IntlDateFormatter' –