Sending Dates to Angular from Laravel
This might not be ideal but so far it allows me to more easily sort dates and filter dates in Angular.
From the Laravel model I add these two methods
/**
* See docs http://laravel.com/docs/5.0/eloquent#date-mutators
*/
public function getDates()
{
return array('created_at');
}
public function getCreatedAtAttribute($attr) {
return Carbon::parse($attr)->timestamp; //Change the format to whichever you desire
}
Then in Angular I can use the filters
{{ vm.created_at | date:'medium'}}
comments powered by Disqus