Reputation: 472
I am trying to get data that match with my giving time, i pass time as a string for now but it gives error,
here is my code
$final_trade = FinalTrade::where('user_id', $user_id)
->where(Carbon::parse('created_at')->format('h:i:s'), '9.30.00')
->first();
here is the error,
DateTime::__construct(): Failed to parse time string (created_at) at position 0 (c): The timezone could not be found in the database
Upvotes: 0
Views: 98
Reputation: 4815
You can use whereTime
directly without parsing,
$final_trade = FinalTrade::where('user_id', $user_id)
->whereTime('created_at', '=', '9:30:00')
->first();
Upvotes: 1
Reputation: 838
The first field in the where method must be the name of the table field
$final_trade = FinalTrade::where('user_id', $user_id)
->where('created_at', '9.30.00')
->first();
please read this laravel query builder
Upvotes: 0
Reputation: 462
You need to pass date in the parse not string https://carbon.nesbot.com/docs/ Read the docs
Upvotes: 0