我開發這個代碼,查看德黑蘭的時間和日期的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' –