How can I format 'time' field - Angularjs and mySql -
i using laravel , angular. have function grabs these records include time field (hh:mm:ss). need display mm:ss portion of value.
i have tried using;
{{ score.time | date: 'mm:ss' }}
but not working.
should trying alter table/col schema never need hh portion anyway or should filtering results - either in laravel(php) or in angular?
this how getting records in laravel
public function scores($id) { return score::where('game', '=', $id) ->get(); }
one way following (taken this answer)
you can create accessor function in post model.
public function gettimeattribute($value) { return date('i:s', strtotime($value)); }
this way, each time you'll call $score->time display date returned accessor instead of default value.
more info here : accessors-and-mutators
if don't want function in models can create basemodel class , make models extend basemodel class.
Comments
Post a Comment