Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

michaelnguyen547's avatar

Date Formats Eloquent Mutators

I am struggle to understand the Date Formats in Model (https://laravel.com/docs/5.5/eloquent-mutators). What is 'U' dateFromat ? Can someone help me to understand it better?

Date Formats
By default, timestamps are formatted as 'Y-m-d H:i:s'. If you need to customize the timestamp format, set the $dateFormat property on your model. This property determines how date attributes are stored in the database, as well as their format when the model is serialized to an array or JSON:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Flight extends Model
{
    /**
     * The storage format of the model's date columns.
     *
     * @var string
     */
    protected $dateFormat = 'U';
}
0 likes
2 replies

Please or to participate in this conversation.