【发布时间】:2017-09-02 03:28:40
【问题描述】:
我需要从模型用户中选择特定年龄的用户,但是出现这个错误:
DateTime::__construct(): Failed to parse time string (birth) at position 0 (b): The timezone could not be found in the database
部分控制器:
$users = User::where(Carbon::parse('birth')->diff(Carbon::now())->format('%y'), '>=', 18)->get();
当我使用它查看所有工作正常时:
@foreach ($userss as $user)
<?php $age_year = Carbon::parse($user->birth)->diff(Carbon::now())->format('%y'); ?>
@endforeach
感谢您的回答!
【问题讨论】:
-
我认为日期时间格式问题
标签: php laravel php-carbon