I have tried to implement datetime picker in Magento2, only date is coming, datetime picker is not appearing,

                'type'                    => 'datetime',
                'backend'                 => 'Magento\Catalog\Model\Attribute\Backend\Startdate',
                'frontend'                => '',
                'label'                   => 'start date',
                'note'                    => 'Add start date with 24 hours time format Ex: mm/dd/yyyy hh:mm:ss(05/01/2017 13:10:10)',
                'input'                   => 'date',
                'frontend_class'          => 'starting_date',
                'source'                  => '',
                'global'                  => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
                'visible'                 => true,
                'required'                => false,
                'user_defined'            => true,
                'default'                 => '',
                'searchable'              => false,
                'filterable'              => false,
                'comparable'              => false,
                'visible_on_front'        => true,
                'used_in_product_listing' => true,
                'unique'                  => false,
                'apply_to'                => '',
                'is_used_in_grid'         => true,
                'is_visible_in_grid'      => true,
                'is_filterable_in_grid'   => true,
                'group'                   => 'CustomAttribute',

I have tried different option including this [url][1]

[1]: Magento 2 Create Date with Time attribute for product anyone have done this, it will be awesome to share.

1 Answer 1


Same link find the solution Magento 2 Create Date with Time attribute for product

I have done validation separately for this, because frontend_class is not appearing in the admin side,Magento is validating based on the frontend_class

added these lines in modules Namespace\Modulename\etc\di.xml file

<type name="Magento\Catalog\Ui\DataProvider\CatalogEavValidationRules">
      <plugin name="namespace_custom_validation_for_product_attribute" type="Namespace\Modulename\Model\Product\ValidationRules"/>

and after that we have added validation rules inside Namespace\Modulename\Model\Product\ValidationRules.php


namespace Namespace\Modulename\Model\Product;

use Closure;

class ValidationRules

     * [aroundBuild description]
     * @param  \Magento\Catalog\Ui\DataProvider\CatalogEavValidationRules $rulesObject
     * @param  Closure                                                    $proceed
     * @param  \Magento\Catalog\Api\Data\ProductAttributeInterface        $attribute
     * @param  array                                                      $data
     * @return array                                                                 [description]
    public function aroundBuild(
        \Magento\Catalog\Ui\DataProvider\CatalogEavValidationRules $rulesObject,
        Closure $proceed,
        \Magento\Catalog\Api\Data\ProductAttributeInterface $attribute,
        array $data
        $rules = $proceed($attribute,$data);
        if($attribute->getAttributeCode() == 'attribute_code'){ //my case attibute_code is starting_date
            $validationClasses = explode(' ', $attribute->getFrontendClass());
            foreach ($validationClasses as $class) {
                $rules[$class] = true;

        return $rules;

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.