3

How can I get datetime as form field.I have used below code able to select date but there is no time. How can I get time also as input field.

$fieldset->addField(
            'time',
            'date',
            [
                'name' => 'time',
                'label' => __('Time'),
                'title' => __('Time'), 
                'disabled' => $isElementDisabled,
                'singleClick'=> true,
                'date_format' => 'yyyy-MM-dd hh:mm:ss',
                'time'=>true
            ]
        );

1 Answer 1

9

Try following way:


$fieldset->addField(
            'time',
            'date',
            [
                'name' => 'time',
                'label' => __('Time'),
                'date_format' => 'yyyy-MM-dd',
                'time_format' => 'hh:mm:ss'
            ]
        );

1
  • Ho Do I add the backend form
    – Jaisa
    Commented Mar 13, 2018 at 4:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.