0

I have been using this method for loading database data into forms:

value="{{$offer->name}}"

This method works with all other input types but not with type="datetime-local" The date and time have been stored in mysql with type datetime.

is their any methods to get the time and date back into the field (datetime-local) ?

Thank you

2 Answers 2

1

The docs at http://dev.w3.org/html5/markup/input.datetime-local.html#input.datetime-local.attrs.value tell me you need to use the specified format: 1996-12-19T16:39:57

The following parts, in exactly the following order:

  • A date.
  • The literal string "T".
  • A time.

So, you need to format the database format to the above format.

Sign up to request clarification or add additional context in comments.

Comments

1

You can use str_replace on your controller and send the value to the view. Something like this:

$offer_name = str_replace(' ', 'T', $offer->name);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.