mardi 29 janvier 2019

Laravel not retrieving milliseconds in DateTime columns

In Laravel, I have some columns with milliseconds. Note that some other columns do not have milliseconds (e.g. created_at, updated_at).

Here is my migration:

Schema::create('brands', function (Blueprint $table) {
    $table->increments('id');
    $table->dateTime('sync_date_time', 3);
    $table->timestamps();
});

My model is simply:

class Brand extends Model {}

Yet when I have a record with milliseconds (e.g. 2018-12-19 01:40:46.512) , and execute:

$brand->sync_date_time;

It always returns a string without the milliseconds portion (e.g. 2018-12-19 01:40:46).

Why is this happening, and how can I fix this issue?

Note that this is not a Carbon issue, as I am not using Carbon for this field at all.



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2RUNZzz
via IFTTT

Aucun commentaire:

Enregistrer un commentaire