jeudi 28 mars 2019

how to show unix timestamp in blade view from created_at or updated_at field in database laravel?

I want to get UNIX timestamp or convert created_at or updated_at date to UNIX timestamp format from database fields (created_at and updated_at) in laravel 5.8 , how can i do this?

this is my code in my controller :

public function viewArchives(){
$data = Archive::select(‘created_at’)->get();
return view(‘view.archives’, compact(‘data’));
}

and in view/archives.blade.php :

<?php echo $data;?>

the result is :

{“created_at”:”2019-03-17 19:10:30″}

but i want the result be like this :

{“created_at”:”1552849830″}

how can get this result?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2HU2sWi
via IFTTT

Aucun commentaire:

Enregistrer un commentaire