简体   繁体   English

Laravel Backpack 进入一个新的时间领域,从 1970 年开始日历

[英]Laravel Backpack Entering a New Time Field Starts Calendar at 1970

Created a Event CRUD object in Laravel Backpack.在 Laravel Backpack 中创建了一个 Event CRUD 对象。 Everytime I add a new Event, the calendar that helps set the time for the event is set to 1/1/1970 12:00 AM.每次添加新事件时,帮助设置事件时间的日历都会设置为 1/1/1970 12:00 AM。 How would I change that field to be defaulted to current day 12:00 AM by default?默认情况下,如何将该字段更改为默认为当天上午 12:00?

1) For the datetime field type : if you define default , that value will be used. 1) 对于datetime字段类型:如果您定义default ,则将使用该值。 So you can do this:所以你可以这样做:

$this->crud->addField([
            'name' => 'datetime',
            'label' => 'Datetime',
            'type' => 'datetime',
            'default' => date("Y-m-d H:i:s"),
        ]);

2) For the datetime_picker field type , the current date will be prepopulated automatically. 2) 对于datetime_picker字段类型,将自动预填充当前日期。

Hope it helps.希望能帮助到你。

        $this->crud->addField([
            'name' => 'datetime',
            'label' => 'Date Time',
            'type' => "datetime_picker",  //use this instead of datetime
            'format' => 'M d,Y H:m',
            'default' => date("Y-m-d 00:00:00"),  //defaults to today at midnight
            'allows_null' => true  //if you want to allow removal of date picked
        ]);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM