我正在尝试用Carbon减去2个时间戳但我收到错误: “Carbon.php第425行中的InvalidArgumentException: 小时不能高于12“
$s = \Carbon\Carbon::now();
$lastlog = \Carbon\Carbon::createFromFormat('y-m-d h:m:i', '16-09-19 14:10:11');
$h = $lastlog->diffForHumans($s);
我也试过
$s = \Carbon\Carbon::now();
$lastlog = \Carbon\Carbon::createFromFormat('y-m-d h:m:i', '16-09-19 14:10:11');
$lastlog = date('y-m-d a h:m:i' , strtotime($lastlog));
$h = $lastlog->diffForHumans($s);
答案 0 :(得分:1)
24小时制的日期格式为H,而不是h:http://php.net/manual/en/function.date.php
所以你想要
$lastlog = \Carbon\Carbon::createFromFormat('y-m-d H:m:i', '16-09-19 14:10:11');