I develop this code to view Tehran time and date with php:
$fmt = new IntlDateFormatter("fa_IR@calendar=persian", IntlDateFormatter::FULL,
IntlDateFormatter::FULL, 'Asia/Tehran', IntlDateFormatter::TRADITIONAL);
echo "Date: " . $fmt->format(time()) . "\n";
this code works fine but, I want to use it in a function in my controller in Laravel.
Route:
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";
}
And the result is :
Class 'App\Http\Controllers\IntlDateFormatter' not found
I know that there is not IntlDateFormatter class in Laravel but I except that use php class here. what is my mistake?
Thanks for response, I forgotted to add
use IntlDateFormatter;
So the not found error solved by adding that.