How change all dates in array into date without time - laravel -


i have collection of model in $object.

then, purpose of delivering data charts.js dates:

var labels = {!! $object->pluck('created_at') !!}; 

the content looks this: ["2014-06-21 13:22:14","2014-06-28 07:42:26","2016-02-17 17:39:21"]

how transform array taht contains dates in format("y-m-d") format?

["2014-06-21","2014-06-28","2016-02-17"] 

for convenience: http://nnnick.github.io/chart.js/docs-v2

in model

class mymodel extends model {     /**      * created_at in date format ==> 1975-12-25      *      * @param  string  $value      * @return string      */     public function getcreatedatdateattribute($value)     {         return $this->created_at->todatestring();     } } 

then

var labels = {!! $object->pluck('created_at_date') !!}; 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -