Level 67
U - Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
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';
}
U - Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)
Please or to participate in this conversation.