[英]Laravel is not saving the date correctly
I've got the issue that my function in Laravel: 我遇到的问题是我在Laravel中的功能:
$case->happened_at = Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $request->happened_at. ' 00:00:01');
Is saving the day of the date not correctly, it is always turning to 1 for the day 保存日期的日期不正确,该日期始终变为1
I already checked my $request->happened_at
with dd() and in this it is correctly shown. 我已经用dd()检查了我的
$request->happened_at
,并在其中正确显示了它。
maybe someone knows a solution 也许有人知道解决方案
您错过了使用toDateTimeString
获取格式化的值
$case->happened_at = Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $request->happened_at. ' 00:00:01')->toDateTimeString();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.