diffForHumans 不起作用 returns 我 分离符号不能 Carbon
diffForHumans does not work returns me The separation symbol could not Carbon
我在我的 MySQL
table fecha
中有一个字段作为日期时间,我想对其应用适当的格式,然后使用 diffForHumans
获取差异但是它显示错误
"message": "The separation symbol could not be found\r\nThe separation
symbol could not be found\r\nData missing",
"exception": "InvalidArgumentException",
"file": "C:\laragon\www\appcolegio\vendor\nesbot\carbon\src\Carbon\Carbon.php",
"line": 582,
我的 class Visita
里有这个
public function getFechaAttribute($value)
{
return Carbon::createFromFormat('d/m/Y H:i:s',strtotime($value))
->timezone('America/Lima');
}
public function getDiffAttribute()
{
$fx = $this->fecha;
return Carbon::createFromFormat('d/m/Y H:i:s',strtotime($fx))
->timezone('America/Lima')
->diffForHumans();
}
在我看来,我想显示这两个值,一方面是当前日期与相应时区的日期,另一方面是与相应时区的差异
如何实现?使用 Laravel 5.5
更改格式自:
d/m/Y H:i:s
收件人:
Y-m-d H:i:s
并删除 strtotime()
我在我的 MySQL
table fecha
中有一个字段作为日期时间,我想对其应用适当的格式,然后使用 diffForHumans
获取差异但是它显示错误
"message": "The separation symbol could not be found\r\nThe separation symbol could not be found\r\nData missing", "exception": "InvalidArgumentException", "file": "C:\laragon\www\appcolegio\vendor\nesbot\carbon\src\Carbon\Carbon.php", "line": 582,
我的 class Visita
public function getFechaAttribute($value)
{
return Carbon::createFromFormat('d/m/Y H:i:s',strtotime($value))
->timezone('America/Lima');
}
public function getDiffAttribute()
{
$fx = $this->fecha;
return Carbon::createFromFormat('d/m/Y H:i:s',strtotime($fx))
->timezone('America/Lima')
->diffForHumans();
}
在我看来,我想显示这两个值,一方面是当前日期与相应时区的日期,另一方面是与相应时区的差异
如何实现?使用 Laravel 5.5
更改格式自:
d/m/Y H:i:s
收件人:
Y-m-d H:i:s
并删除 strtotime()