Soul Coder
Soul Coder

Reputation: 804

How to display timestamp format in edit form in laravel?

I am trying to write update function in laravel, and I am trying to get the old value in edit form, the text fields are easy to retrive back in the form, and also date fields is also working, but for the timestamp field, I coudn't able to get the old value.Please help me out.This simple date field is working.

  <input type="date" value="{{Carbon\Carbon::parse($package->start_date)->format('Y-m-d')}}" name="start_date">

But for the timestamp field, I tried many format, for example like

 <input type="datetime-local" value="{{Carbon\Carbon::parse($package->start_date)->format('Y-m-d H:i:s')}}" name="start_date">

Upvotes: 3

Views: 2425

Answers (1)

Yamen Ashraf
Yamen Ashraf

Reputation: 2960

For date input type use toDateString() method, for datetime-local input type use toDateTimeLocalString() or format('Y-m-d\TH:i:s')

Upvotes: 5

Related Questions