The important bits are the date_format and time_format keys.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Guys,
I'm using Magento CE 2.2.4 and I wanna add time in datepicker in backend. Especially on Special price section. I want the datepicker to be displayed like this with time (hour and minute selection option)
Can any one help how to show the time? I'll be grateful to you.
TIA
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @fahmad
sorry for late replay, today i get some time and i checked and i found it is coming from
Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AdvancedPricing.php
into bottom of area line 579 around
$this->meta = $this->arrayManager->merge( $pathFrom . '/arguments/data/config', $this->meta, [ 'label' => __('Special Price From'), 'scopeLabel' => null, 'additionalClasses' => 'admin__field-date', 'options' => ['showsTime'=>true] // add this line to show time ] );
i did not checked save and all thing work. also, you need to create a plugin for add this.
Hope it will help you.
If help you then mark as a solution
Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: How to show Time in datepicker in magento 2x backend?
You want to have the declaration of the field similar to the following;
$fieldset->addField( 'date_to', 'date', [ 'name' => 'date_to', 'label' => __('Start Time'), 'title' => __('Start Time'), 'date_format' => $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT), 'time_format' => $this->_localeDate->getTimeFormat(\IntlDateFormatter::SHORT), 'class' => 'validate-date' ] );
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @fahmad
sorry for late replay, today i get some time and i checked and i found it is coming from
Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AdvancedPricing.php
into bottom of area line 579 around
$this->meta = $this->arrayManager->merge( $pathFrom . '/arguments/data/config', $this->meta, [ 'label' => __('Special Price From'), 'scopeLabel' => null, 'additionalClasses' => 'admin__field-date', 'options' => ['showsTime'=>true] // add this line to show time ] );
i did not checked save and all thing work. also, you need to create a plugin for add this.
Hope it will help you.
If help you then mark as a solution
Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: How to show Time in datepicker in magento 2x backend?
Thanks a lot @Sunil Patel
It worked. Even I don't have to create a plugin for this.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: How to show Time in datepicker in magento 2x backend?
Hello @fahmad
we can not able to change into core file
Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: How to show Time in datepicker in magento 2x backend?
I have a way to do this editing more cleanly, without touching the Core Magento file. It's late for this post but I hope it helps someone.
Magento 2.4.5 - 2.4.6
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <!-- Plugings --> <type name="Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AdvancedPricing"> <plugin name="vendor_module_plugin" type="Vendor\Module\Plugin\Ui\DataProvider\Product\Form\Modifier\AdvancedPricingPlugin" sortOrder="1"/> </type> </config>
<?php namespace Vendor\Module\Plugin\Ui\DataProvider\Product\Form\Modifier; class AdvancedPricingPlugin { public function afterModifyMeta( \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AdvancedPricing $subject, $result ) { $result['advanced_pricing_modal']['children']['advanced-pricing']['children'] ['container_special_from_date']['children']['special_from_date']['arguments'] ['data']['config']['options'] = ['showsTime' => true]; $result['advanced_pricing_modal']['children']['advanced-pricing']['children'] ['container_special_from_date']['children']['special_to_date']['arguments'] ['data']['config']['options'] = ['showsTime' => true]; return $result; } }