@noblemfd use accesor in your model or in your app.config add some code like this 'date_format' => 'd/m/Y', 'date_format_javascript' => 'DD/MM/YYYY', then pull it in all view or controller .
are u from Ethiopia?
Jun 24, 2020
6
Level 9
How to force date format to dd/mm/yyyy
In my Laravel-5.8 project, I have this code:
Model
protected $fillable = [
'name',
'start_date',
'end_date',
];
protected $dates = [
'start_date',
'end_date'
];
View:
<td>
<input type="date" name="start_date[]" placeholder="dd/mm/yyyy" class="form-control start_date" min="{{Carbon\Carbon::now()->firstOfYear()->format('Y-m-d')}}" max="{{Carbon\Carbon::now()->lastOfYear()->format('Y-m-d')}}">
</td>
<td>
<input type="date" name="end_date[]" placeholder="dd/mm/yyyy" class="form-control end_date" min="{{Carbon\Carbon::now()->firstOfYear()->format('Y-m-d')}}" max="{{Carbon\Carbon::now()->lastOfYear()->format('Y-m-d')}}">
</td>
With this, I expected the date to display as dd/mm/yyyy, but it still comes as mm/dd/yyyy
Some systems display it as dd/mm/yyyy while others as mm/dd/yyyy
However, I want it to be:
dd/mm/yyyy
How do I resolve this?
Thank you
Level 2
@noblemfd it should work
<?php
return [
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services the application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => env('APP_DEBUG', false),
/*
Date Format
*/
'date_format' => 'd/m/Y',
'date_format_javascript' => 'DD/MM/YYYY',
it is not working, try mutators
in your model
protected $dates = [
'created_at',
];
public function getCreatedFormatAttribute()
{
return $this->created_at->format('d-m-Y');
}
protected $appends = ['created_format'];
then in view blade do this
{{$anyVarible->created_format}}
Please or to participate in this conversation.