First I retrieve all the records,
$inv = inventory::all();
and then I loop through the extracted records and modify the created_at and updated_at data to make it more human-readable by date.
foreach($inv as $i){
$i->created_at = date("M d, Y",strtotime($i->created_at));
$i->updated_at = date("M d, Y",strtotime($i->updated_at));
}
but he returns me this error,
InvalidArgumentException in line Carbon.php 425: Unexpected data found. Unexpected data received. Separation character not found Missing data
any ideas, help, tips, suggestions, recommendations, please
here is my model
namespace App;
use Illuminate\Database\Eloquent\Model;
class inventory extends Model
{
protected $table = "inventory";
protected $primaryKey = "item_id";
public $incrementing = false;
public function profile(){
return $this->belongsTo('App\profile','username');
}
public function inventory_images(){
return $this->hasMany('App\inventory_images','item_id');
}
}
and in the blade i can just use
{{ date("M d, Y",strtotime($i->created_at)) }}
{{ date("M d, Y",strtotime($i->updated_at)) }}
and it works fine.
source
share