php 在Laravel中,如何更改日期和时间格式以显示完整的葡萄牙语?

sg24os4d  于 2023-02-15  发布在  PHP
关注(0)|答案(1)|浏览(300)

在Laravel中,如何更改日期和时间格式以显示完整的葡萄牙语?具体来说,我希望以“DIA da SEMANA,DIA de MS de ANO às HORAS:HORAS:SEGUNDOS”格式显示日期和时间。在Laravel中设置默认语言和日期格式的正确方法是什么?是否需要更改任何特定的配置文件或代码?
我想将Laravel中的日期和时间格式完全更改为葡萄牙语。已经尝试过各种方法更改,但失败了。我使用碳dddd,MMMM D,YYYY h更改了格式:mm A指令,但无法

UserController.php

$dL = [];
$dV = [];
foreach(array_reverse($stack) as $d) {
    $dL[]. = Date::parse($d)->format('dS M');

}

foreach(array_reverse($stack) as $d) {
    $date = Carbon::parse($d)->format('Y-m-d');
    $start = $date.
    ' '.
    '00:00:00';
    $end = $date.
    ' '.
    '23:59:59';
    $dC = Signal::whereBetween('created_at', [$start, $end])->get();
    $dV[]. = count($dC);
}

$data['dV'] = $dV;
$data['dL'] = $dL;

return view('user.dashboard', $data);
}

signal-all.blade.php

@php
    $p = 0;
@endphp

@foreach($signal as $k => $p)
<tr>
    <td>{{ $k + $signal->firstItem() }}</td>
    <td>{{\Jenssegers\Date\Date::parse($p->created_at)->format('dS M, Y - h:i:s A')}}</td>
    <td>{{ $p->signal->title }}</td>
    <td>{{ $p->signal->asset->name }} - {{ $p->signal->symbol->name }} - {{ $p->signal->type->name }}</td>
    <td>{{ $p->signal->frame->name }} - {{ $p->signal->status->name }}</td>

App.php

'timezone' => 'America/Sao_Paulo',

    /*
    |--------------------------------------------------------------------------
    | Application Locale Configuration
    |--------------------------------------------------------------------------
    |
    | The application locale determines the default locale that will be used
    | by the translation service provider. You are free to set this value
    | to any of the locales which will be supported by the application.
    |
    */

    'locale' => 'pt',

    /*
    |--------------------------------------------------------------------------
    | Application Fallback Locale
    |--------------------------------------------------------------------------
    |
    | The fallback locale determines the locale to use when the current one
    | is not available. You may change the value to correspond to any of
    | the language folders that are provided through your application.
    |
    */

    'fallback_locale' => 'pt',
lmvvr0a8

lmvvr0a81#

有一个支持多种语言的日期时间Laravel包用于这种类型的输出。您可以检查. https://github.com/jenssegers/date
易于使用

use Jenssegers\Date\Date;

日期::设置区域设置('pt ');//用于葡萄牙语
echo日期::now()-〉格式('l j F Y H:i:s ');//萨巴多2019年11月9日13:45:03
超声心动图日期::分析("-1天")-〉人类差异();//1个字符

相关问题