First, I retrieve all the records,
//get inventory items $inv = inventory::all();
and then I loop on the retrieved records and modify the created_at and updated_at data to make it more human readable 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 it returns me this error,
InvalidArgumentException in Carbon.php line 425: Unexpected data found. Unexpected data found. The separation symbol could not be found Data missing
any ideas, help, clues, suggestions, recommendations please?
here's 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 blade, I can just use
{{ date("M d, Y",strtotime($i->created_at)) }} {{ date("M d, Y",strtotime($i->updated_at)) }}
and it work just fine.