ITPub博客

首页 > 应用开发 > > 求解答,谢谢谢谢

求解答,谢谢谢谢

作者:mex 时间:2019-08-06 11:40:10 0 删除 编辑

Laravel eloquent timestamps ($dateFormat)的设置对 mysql 表的 timestamps 类型字段是如何起作用的?

今天我阅读 Laravel 5.3 文档 Eloquent 一节的 Timestamps 这一小节的内容时,看到

If you need to customize the format of your timestamps, 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

namespaceApp;

useIlluminate\Database\Eloquent\Model;

    

classFlight extendsModel

{

    /**

     * The storage format of the model's date columns.

     *

     * @var string

      */

    protected$dateFormat= 'U';

}

我使用 mysql 数据库,有 created_at 和 updated_at 两个字段,字段类型是 timastamps 。

我设置了

1$dateFormat= 'U'

按照它的说法,我可以 “customize the format of my timestamps”,具体是如何使用的呢?

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/3932/viewspace-3155871/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: c# 语法..
请登录后发表评论 登录
全部评论

注册时间:2019-07-09

  • 博文量
    193
  • 访问量
    1886