Sending Dates to Angular from Laravel

Posted: 2015-02-24 00:51:59

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 */ 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'}}