【发布时间】:2018-03-01 22:17:40
【问题描述】:
我想使用 Carbon 从月份名称中获取月份索引。
但我使用土耳其月份名称。
我将查询字符串传递给像这样?ay=Temmuz&yıl=2017 这样的索引,因此在这种情况下碳应该给出 7。
我的索引函数中的相关部分是这样的:
public function index()
{
$gonderiler = Gonderi::latest();
if ($ay = request('ay'))
{
Carbon::setLocale(config('app.locale'));
$gonderiler->whereMonth('created_at', Carbon::parse($ay)->month);
}
if ($yil = request('yil'))
{
$gonderiler->whereYear('created_at', $yil);
}
/ ... /
}
当我单击侧栏并传递此查询字符串时,它会给出如下错误消息:
"DateTime::__construct(): 解析时间字符串 (Temmuz) 失败 位置 0 (T):在数据库中找不到时区"
【问题讨论】:
-
你使用的服务器是什么?
-
我在 64 位 Ubuntu 机器上使用 vallet。带有 Laravel 框架 5.5.3 的 Ubuntu 16.04 LTS
标签: php laravel laravel-5 php-carbon