Laravel 5.1: Accessor method for created_at date not working

Wednesday, November 4, 2015

Following is a record in Postgresql table's column labelled as 'created_at' :



2015-11-04 07:39:56


I have following Model:



class SecurityQuestionListModel extends Model {
protected $table = 'security_question_list';

protected $dates = ['created_at'];

protected $dateFormat = 'Y-m-d H:i:s';

protected $casts = [
'status' => 'boolean',
];

public function getCreatedAtAttribute($date){
return \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $date)->format('Y-m-d H:i:s');
}


}



I am getting value as:



November 04, 2015


Can some one guide me what I am doing wrong that I am unable to display hours minutes and seconds.

0 comments:

Post a Comment