gpt4 book ai didi

mysql - 在 Laravel 中从数据库获取数据时出现错误

转载 作者:行者123 更新时间:2023-11-29 06:43:20 25 4
gpt4 key购买 nike

我正在尝试获取与我的给出时间匹配的数据,我现在将时间作为字符串传递,但它给出了错误,

这是我的代码

$final_trade = FinalTrade::where('user_id', $user_id)
->where(Carbon::parse('created_at')->format('h:i:s'), '9.30.00')
->first();

这是错误,

DateTime::__construct(): Failed to parse time string (created_at) at position 0 (c): The timezone could not be found in the database

最佳答案

可以直接使用whereTime,无需解析,

$final_trade = FinalTrade::where('user_id', $user_id)
->whereTime('created_at', '=', '9:30:00')
->first();

关于mysql - 在 Laravel 中从数据库获取数据时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50655764/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com