Eloquent models cast their timestamp fields created_at and updated_at to Carbon instances - which is assumed to be the database default Y-m-d H:i:s (in most circumstances). Because you are changing the format, Carbon cannot create an instance using the default format, hence the data missing error. If you want to modify the datetime for display purposes, do it at an appropriate level in your application, e.g. using an accessor method in the model class, or at the presentation level in your view template, or JSON transformer.
oh so if i want to retrieve a data with date_format of 'Y-m-d H:i" only is it possible. My target right now is to retrieve data and ignore the second value.
Thank you @nakov i tried your way and i could not get any output from table, it keep on saying data missing. I tried to make query from my mysql to check if my query is right or not and the query return a data. But when i tried putting it inside my selectRaw it does not return any value? Could you help me with this.
My real intention is just to get data within the date range (Y-m-d H:i) of created_at, I cannot change or add column into the table as the data already exist.
In this post, i share with you that how to use date_format() with where condition of Laravel query builder. When i was working on my project, i require to search with get only selected month and year records from created_at(timestamp) column https://www.prepaidgiftbalance.vip/