我开发此代码来使用 php 查看德黑兰时间和日期:
$fmt = new IntlDateFormatter("fa_IR@calendar=persian", IntlDateFormatter::FULL,
IntlDateFormatter::FULL, 'Asia/Tehran', IntlDateFormatter::TRADITIONAL);
echo "Date: " . $fmt->format(time()) . "\n";
这段代码工作正常,但是,我想在 Laravel Controller 的函数中使用它。
路线:
Route::get('/date', [
'as' => 'date', 'uses' => 'HomeController@date'
]);
Controller :
public function date() {
$fmt = new IntlDateFormatter("fa_IR@calendar=persian", IntlDateFormatter::FULL,
IntlDateFormatter::FULL, 'Asia/Tehran', IntlDateFormatter::TRADITIONAL);
echo "Date: " . $fmt->format(time()) . "\n";
}
结果是:
Class 'App\Http\Controllers\IntlDateFormatter' not found
我知道 Laravel 中没有 IntlDateFormatter 类,但我除了在这里使用 php 类。我的错误是什么?
最佳答案
感谢您的回复,我忘了添加
use IntlDateFormatter;
因此,通过添加该内容解决了未找到的错误。
关于php - 未找到类 'App\Http\Controllers\IntlDateFormatter',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35222133/