@kirchaj
I think that the date format belongs to the presentation layer (frontend), then a good datepicker js lib will let you give format to the date displayed.
As i can see in your code, you are using HTML5 date input field, this input only displays a date that is in yyyy-mm-dd, if you throw your date field from your model into this input, it will not display the date. This happened to me and waste lot of time scratching my head until i knew about it.
The issue was that when a carbon object is converted to string, it gives you a date formatted like yyyy-mm-dd hh:mm:ss.
The html date input field does not recognize this format.
What to do?
Creating the accesor method is good if you are not going to use it as a Carbon object, otherwise, you are losing all the functionality it gives you.
You can use the laracasts/presenter package to create a presenter for your model, where you output the date formatted as yyyy-mm-dd without the time.
class StudentPresenter
{
public function birthday()
{
return $this->entity->birthday->format('Y-m-d');
}
}
Then in your view:
<div class="form-group col-sm-6 col-lg-4">
{!! Form::label('birthdate', 'Birthday:') !!}
{!! Form::input('date', 'birthdate', $student->present()->birthday, ['class' => 'form-control']) !!}
</div>
Now, using Chrome it will format the date to the user system's regional settings.
For example, if a student has a birthdate of 1985-10-13 00:00:00 stored in the database, the presenter will put in the view just 1985-10-13, and if i am viewing the page from my computer configured with a region of Mexico where most people speaks spanish and dates are formatted like dd-mm-yyyy i will see the date like 13-10-1985.
If i change the date, it will be sent as yyyy-mm-dd without doing anything, this will keep out of my application how the dates are displayed to the client and stick to the database ISO standard date format.
Thing get a little messy when you want to have a javascript datepicker, i suggest you to try http://amsul.ca/pickadate.js/date/, this is a real good library to display a date picker for desktop or mobile, and have flexible configuration options.
Check it out and if you have more answers please reply.
I had a hard time to figure it out by myself but i learned a lot and i would like to help you and learn more.