我的应用程序中有来自前端的这个日期:
'13-07-2017 14:00'
我会测试:
try{
Carbon::createFromFormat('d-m-Y H:i', $date);
}catch (\Exception $err){
return false;
}
为什么总是返回这个错误?
InvalidArgumentException : Hour can not be higher than 12
in Carbon.php (line 582) at Carbon::createFromFormat('d-m-Y h:i', '13-07-2017 14:13')
所以我使用 CAPITAL H ,但我的异常是用 'h' 引发的
最佳答案
所以这里的问题是你使用了小写的h
。您粘贴了代码 H:i
,但从异常情况来看,很明显您使用了 h:i
。
关于php - 碳 "Hour can not be higher than 12",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45083142/