Reputation: 8085
using a date time picker and it keeps inserting 0000-00-00 00:00:00 into my TIMESTAMP 'time' field.
When printing out the requested input it shows:
04/08/2016 12:00 AM
What do I need to do to allow that to be inserted correctly into my database?
Upvotes: 0
Views: 1426
Reputation: 15457
The date you are using in the input is in the incorrect format for MySQL.
Before inserting the date into the database, convert it into a compatible format, e.g.:
date( 'Y-m-d H:i:s', strtotime( $request->input('date') ) );
This assumes your input field is called date
(please change accordingly). The above code coverts the date from your input field into a unix timestamp, and then formats it to YYYY-MM-DD HH:MM:SS
format.
Upvotes: 1