Magento – Magento 2 : Add Date Picker in 24 Hour Format in Admin Form

adminformadminhtmldatepickermagento2

I want to add date picker in admin form which display 24 hour format. Currently , I select date then it will display like 4/25/17 5:21 PM

But I want to display like this 2017-04-25 17:21:00

How to do it?

Please help me….

Thanks in advance…. 🙂

$fieldset->addField(
        'from_date',
        'date',
        [
             'name' => 'from_date',
            'label' => __('From'),
            'title' => __('From'),
            /*'date_format' => 'yyyy-MM-dd',
            'time_format' => 'hh:mm:ss'*/
            'date_format' => $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT),
            'time_format' => $this->_localeDate->getTimeFormat(\IntlDateFormatter::SHORT),
        ]

    );

Best Answer

Change it to:

'date_format' => \Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT,
'time_format' => 'HH:mm:ss',

Hope it helps :)

Related Topic