mercredi 4 novembre 2015

Laravel 5.1: Accessor method for created_at date not working

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.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire